You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using null resource to create views in AWS Athena by running aws cli commands and they get properly created and destroyed with the apply and destroy commands. But if I remove/comment the resource it doesn't run the command, to put you in context here is the code:
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
I'm using null resource to create views in AWS Athena by running aws cli commands and they get properly created and destroyed with the apply and destroy commands. But if I remove/comment the resource it doesn't run the command, to put you in context here is the code:
Module
`resource "null_resource" "views" {
triggers = {
md5 = filemd5("queries/${var.sql_file}")
athena_results_bucket = var.athena_results_bucket
athena_database = var.athena_database
sql_file = var.sql_file
}
provisioner "local-exec" {
command = <<EOF
aws athena start-query-execution
--output json
--query-string file://queries/${var.sql_file}
--query-execution-context "Database=${self.triggers.athena_database}"
--result-configuration "OutputLocation=s3://${self.triggers.athena_results_bucket}"
EOF
}
provisioner "local-exec" {
when = destroy
command = <<EOF
aws athena start-query-execution
--output json
--query-string 'DROP VIEW IF EXISTS ${replace(self.triggers.sql_file,".sql","")}'
--query-execution-context "Database=${self.triggers.athena_database}"
--result-configuration "OutputLocation=s3://${self.triggers.athena_results_bucket}"
EOF
working_dir = path.module
}
}`
Main using the module
`module view {
source = "./build"
athena_results_bucket = "bucket.athena-results"
athena_database = "extract"
sql_file = "view.sql"
}
module another_view {
source = "./build"
athena_results_bucket = "bucket.athena-results"
athena_database = "extract"
sql_file = "view_2.sql"
}`
By commenting any of the modules after apply, it should just run the second provider in the resource, but it doesn't.
The text was updated successfully, but these errors were encountered: