Best Practice to Remove Resources? #75
-
Hi Folks, We did our first test last week for the SDLC... with a simple instance creation/deletion attempt. Here was our assumption ASSUMPTION: REALITY: QUESTION: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That behavior is expected — deleting code or reverting a PR doesn’t affect the Terraform state, so resources won’t be destroyed unless explicitly handled. Destroying resources can be risky and non-trivial, so it’s best to make the process intentional and traceable. The recommended approach is to use the Please see this tutorial for deleting components with Spacelift — many of the same concepts apply, even if you’re not using Spacelift: Alternatively, we have some customers that have created workflows specifically to orchestrate deployment and cleanup of developer environments. This is a more advanced pattern that's specific to the use case — happy to discuss further if that’s something you’re interested in exploring. Finally for broader cleanup, tools like aws-nuke or cloud-nuke can be used to tear down entire environments. We use this in our testing sandbox accounts. |
Beta Was this translation helpful? Give feedback.
That behavior is expected — deleting code or reverting a PR doesn’t affect the Terraform state, so resources won’t be destroyed unless explicitly handled. Destroying resources can be risky and non-trivial, so it’s best to make the process intentional and traceable.
The recommended approach is to use the
enabled
variable built into all Cloud Posse modules and components. By settingenabled: false
for a given component in a PR, you tell Terraform to remove all resources from state and therefore destroy all associated resources on the next apply. This provides an auditable way to deprovision infrastructure that we can trace through pull requests. Keep in mind, however, that this method doesn…