Skip to content
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

How to destroy the infra created by Terraform #154

Open
skdubey opened this issue May 27, 2021 · 4 comments
Open

How to destroy the infra created by Terraform #154

skdubey opened this issue May 27, 2021 · 4 comments

Comments

@skdubey
Copy link

skdubey commented May 27, 2021

Hi,

I was able to run terraform-plan and terraform-apply (two separate actions under same Job) to create AWS resources, Which is working fine. However, it raised a question that How can I destroy the resources created by Concourse pipeline either all or a specific resource?

Also, I observed that when Concourse pipeline is created, I have to run terraform-plan and terraform-action manually to run it. Is there way to run all the actions mentioned under same job sequentially?

@ljfranklin
Copy link
Owner

See put.params.action for running terraform destroy: https://github.com/ljfranklin/terraform-resource#put-parameters. This will destroy all resources listed in the statefile, the resource doesn't support destroying a specific resource as that's strongly discouraged by Terraform.

Also, I observed that when Concourse pipeline is created, I have to run terraform-plan and terraform-action manually to run it. Is there way to run all the actions mentioned under same job sequentially?

Does your job have trigger: true on one of the resources, e.g. https://concourse-ci.org/git-trigger-example.html? Not sure I understand the question.

@skdubey
Copy link
Author

skdubey commented May 27, 2021

Thanks @ljfranklin again for quick response and help.
Regarding destroy, I went through the doc but couldn't understand much. Do we have any sample example for this?
Regarding trigger, thanks for pointing, it was set to "false". I will test with "true".

@ljfranklin
Copy link
Owner

Destroy example:

- put: terraform
resource: terraform-s3-backend
params:
env_name: s3-backend-env
action: destroy
vars:
object_key: ci-pipeline/track1
object_content: "terraform is still neat!"
get_params:
action: destroy

@skdubey
Copy link
Author

skdubey commented May 28, 2021

Great, thanks a lot again.
It's sufficient for me to start with and explore more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants