-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
null ressource not destroying when used as a module #29161
Comments
Duplicate of #13549 |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: