Skip to content

[Feature] Automatically delete table on destroy  #12

@sblack4

Description

@sblack4

The module uses a null_resource with triggers to create the Athena table with the AWS CLI.
It turns out using the provisioner destroy time provider to destroy the table isn't possible because running the destroy command requires inputs that aren't available during a destroy (see error below).

│ Error: Invalid reference from destroy provisioner
│ 
│   on .terraform/modules/elblogging_bucket/athena.tf line 37, in resource "null_resource" "create_table":
│   37:     command = templatefile("${path.module}/templates/delete_table.sh.tpl", {
│   38:       results_config    = "OutputLocation=s3://${aws_s3_bucket.this.bucket}/elblogging-athena-results"
│   39:       execution_context = "Database=${aws_athena_database.this[0].id}"
│   40:     })
│ 
│ Destroy-time provisioners and their connection configurations may only reference attributes of the related resource, via
│ 'self', 'count.index', or 'each.key'.
│ 
│ References to other resources during the destroy phase can cause dependency cycles and interact poorly with
│ create_before_destroy.

Right now the work-around is to provide the aws cli command to delete the table as an output to the module.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions