ljfranklin / terraform-resource

A concourse resource to create infrastructure via Terraform
MIT License
185 stars 85 forks source link

Support 'refresh' operation #141

Closed derjust closed 3 years ago

derjust commented 3 years ago

We use the Terraform resource type to manage all our infrastructure. While it works great to create infrastructure, the destroy part causes some trouble.

In the end, all those issues relate around the fact that (yet) Terraform doesn't refresh its data sources during a destroy. While is addressed in v0.15 eventually, almost all workarounds to this require the use of refresh. For example around EKS:

It would be great to have - like plan_only - an option to let the Terraform resource refresh all it's date, and update the remote state if configured.

ljfranklin commented 3 years ago

I'd rather not add a workaround to the resource when the underlying issue is already fixed in the next Terraform version. As a temporary workaround, could you add a put: terraform step just before the destroy step? That way the terraform apply will refresh the state just before the destroy action.

Alternatively you can try temporarily running the destroy step with the ljfranklin/terraform-resource:rc image which contains the latest Terraform 0.15 alpha. Note that the RC images don't run through my CI pipeline, there's a chance the resource will need updated to be compatible with Terraform 0.15.