ekristen / aws-nuke

Remove all the resources from an AWS account
https://ekristen.github.io/aws-nuke/
MIT License
33 stars 6 forks source link

[Idea] Delete EC2 Instance `Name` Tags On Termination #138

Closed Petersoj closed 3 months ago

Petersoj commented 3 months ago

When an EC2 instance is terminated, the instance stays in the terminated state for about an hour, then it disappears from the AWS account. The problem with this is that once aws-nuke finishes by terminating all EC2 instances in the AWS account, the EC2 instances are still leftover in the account. So if subsequent infrastructure migrations create EC2 instances with names (using the Name tag), then the migrations could run into issues because there are now multiple EC2 instances with the same name. For example, a running instance and a terminated instance both with the Name tag value of "webserver". So it might be a good idea if aws-nuke deletes the tags of all EC2 instances before terminating them.

ekristen commented 3 months ago

I've run into this in the past, I think it's just the Name tag that causes the conflict. Removing all the tags would be the easiest approach, I don't immediately see a downside to this approach.

The other option would be to rename the instance to indicate it was terminated by aws-nuke, but that introduces a few extra checks that would have to happen.

Petersoj commented 3 months ago

Yeah I imagine removing all the tags on an EC2 instance would fix this issue and not cause any unintended issues. PR for it: #141 (my first time working in Go which was pretty fun)

ekristen commented 3 months ago

hey @Petersoj thanks for your PR, sounds like I need to write up some documentation on how to edit your previous commits so you don't have to close out and re-open, you can always edit and force push to make changes like signing or message syntax.

Petersoj commented 3 months ago

Yeah I was considering force pushing, but I was reading up on how that isn't the best practice in most cases. Perhaps it was permissible in this case though.

ekristen commented 3 months ago

@Petersoj when you are working on a PR it's fine generally speaking. You just don't want to be doing force pushes on primary branches/release branches, etc where others are working or where the history is at, when it comes to a new feature and doing a PR, force pushes are normal, because you might amend commits or rebase of the current main branch to make sure you are up to date or to resolve conflicts, etc.