
Those resources must only be deleted when run from the master branch. Unique environments can share reference components in a qa1 environment however, when terraform destroy is run must not delete those resources.Every other branch or PR should have it's own unique environment.By proper I mean environments like qa1, uat, production. The master branch will build all proper environments.The use case I am trying to complete has three broad assumptions They should be able to have their own sandbox to test in until they changes are successful and can be merged. With the potential of more than one developer working on terraform at the same time, they each should be able to make changes and consume underlying modules without reliance on someone else to not only merge into master while also taking down an existing environment to do their testing. To summarize the use case, I want each developer who is developing terraform to be able to develop their own terraform in isolation while testing in isolation to ensure that when something is merged to master it has been through a build/testing process. If you're on a branch, then TerraformDestroyEnvironmentStage might run a terraform plan -destroy, but not provide the user the ability to actually destroy the environment without merging into master.

For one-to-one behavior, I think I would make TerraformDestroy behave the same way too. TerraformEnvironmentStage also behaves differently in master vs a branch.


I'd have the ability to interact with the environment.Def validate = new TerraformValidateStage()ĭef deployQa = new TerraformEnvironmentStage('qa')ĭef destroyQa = new TerraformDestroyEnvironmentStage('qa')
