How to address a timeout error related to aws_lakeformation_permissions for table or table_with_columns
Problem:
- The aws_lakeformation_permissions Terraform resource does not support the timeout configuration, and the default timeout is only one minute.
Solution:
If you are getting this Terraform error when deploying aws_lakeformation_permissions with a table or table_with_columns configuration:
- Error: reading Lake Formation permissions: timeout while waiting for state to become ‘AVAILABLE’ (last state: ‘NOT FOUND’, timeout: 1m0s)
- You can use a combination of aws_lakeformation_data_cells_filter and aws_lakeformation_permissions to address this error.
The following code demonstrates how to implement this solution:
resource "aws_lakeformation_data_cells_filter" "example" {
table_data {
database_name = "<Your_Database_Name>"
name = "<Your_Data_Cells_Filter_Name>"
table_catalog_id = "<Account_ID_of_Data_Catalog>"
table_name = "<Your_Table_Name>"
column_names = ["Replace", "with", "Column", "Names"]
row_filter {
filter_expression = "TRUE" # TRUE means all rows; change this expression if you want to filter rows
}
}
timeouts {
create = "2m" # the default is 2 minutes, but can increase if needed
}
}
resource "aws_lakeformation_permissions" "example" {
permissions = ["<Update to List of Permissions>"]
principal = "<Your_Principal>"
data_cells_filter {
database_name = aws_lakeformation_data_cells_filter.example.table_data[0].database_name
name = aws_lakeformation_data_cells_filter.example.table_data[0].name
table_catalog_id = aws_lakeformation_data_cells_filter.example.table_data[0].table_catalog_id
table_name = aws_lakeformation_data_cells_filter.example.table_data[0].table_name
}
}
The aws_lakeformation_data_cells_filter Terraform resource supports the timeout configuration. When used in combination with the aws_lakeformation_permissions resource, you can deploy the same permissions, without facing a timeout error.
Other Benefits:
- The aws_lakeformation_data_cells_filter resource also provides row filter configuration, which allows for finer-grained access permissions.
Terraform References: