I have created the following resources using Terraform:
aws_athena_database: Amazon Athena database
aws_glue_catalog_table: A CSV table for Athena
It is easy to change my my primary workgroup's default location for query results in the AWS console:
How can I achieve this using Terraform?
I have specified a custom bucket argument for the aws_athena_database to store my query results, which works well if I'm querying outside the Athena console (like Tableau), but if I'm working in the Athena console it defaults to a generic Athena-provided S3 bucket.
You want to us something like this in your terraform, however; this will produce an error because the workgroup already exists, so you will need to use terraform import in order to make terraform add this pre-existing resource to your state file:
terraform import aws_athena_workgroup.primary primary
resource "aws_athena_workgroup" "primary" {
name = "primary"
depends_on = [aws_s3_bucket.my-results-bucket]
configuration {
enforce_workgroup_configuration = false
publish_cloudwatch_metrics_enabled = true
result_configuration {
output_location = "s3://${aws_s3_bucket.my-results-bucket.bucket}/"
encryption_configuration {
encryption_option = "SSE_S3"
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With