Here is what I’m guessing is a pretty common scenario, I have a stack, new guy went in and deleted something inside the stack manually, now clearly I have “drift” detected. But is there a way to re-create this deleted resource automagically? Or does drift detection just tell me it’s missing, but I have to go recreate it manually (if I want it to be outside the stack), or I have to recreate the entire stack?
lame, thanks. do you know if termination protection applies to any resource in the stack, or only if you try to delete the entire stack? docs say it only protects the entire stack.. which seems like another big limitation imo
From the other angle, if the stack has drifted because of manual deletion of assets/services no longer used, is there any way to delete the stack without it deleting any remaining stray resources?
Yes, there now appears to be an option to “retain” resources when deleting the stack. To trigger the dialog in the console, you first have to get the delete to fail - it will then prompt you with a list of resources it failed to delete, and give you the option to retain each one while deleting the stack. Might be a way through the cmdline to just “dissolve” the stack and keep the resources.
I dont believe this is true.. you described why the drift detection is needed. Cloudformation will reapply things if the new template info differs from the last template info. If in the real world someone deletes a port on a security group, and you re-run the template it says “NEW:443, LAST: 443 - NO ACTION!” and doesn’t re-apply them.. i.e. drift.
Apologies, yes I just tested this and you’re right - I must have been getting it confused with something else, possibly Terraform behaviour. Deleted the original comment so there’s no confusion!
What would your next step be, though? Until CF has some option like Terraform’s ‘import’ to bring a pre-existing resource under control of a stack definition, you’re just making the problem worse by deleting the stack and leaving behind all the resources with the names you want to use.