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

GC AWS Old Images (from packer) #2846

Closed
3 tasks done
smerle33 opened this issue Mar 22, 2022 · 7 comments
Closed
3 tasks done

GC AWS Old Images (from packer) #2846

smerle33 opened this issue Mar 22, 2022 · 7 comments
Assignees

Comments

@smerle33
Copy link
Contributor

smerle33 commented Mar 22, 2022

Service(s)

AWS

Summary

handle a Garbage Collector to remove OLD AMI version

Should be split in 3 steps :

Reproduction steps

No response

@dduportal
Copy link
Contributor

Reminder of the "rules" for the GC of AMIs (I can't find my previous comment so I'm adding it here as asked :) ).

Rule of thumb I propose is "1d, 1m, 1y":

  • "Dev" images (e.g. created by a PR build or a developer local build): if an AMI tagged as "dev" is older than 24h, then 🗑️
    • Rationale: these images are short lived, only to demonstrate that a PR does not break the build and have the intented purpose.
  • "Staging" images (e.g. created by a build of the main branch, which purpose it to ensure that "it just works"): if an AMI tagged as "staging is older than 1 week, then 🗑️
    • Rationale: the principal branch is built once per week, hence no need to keep older versions
  • "Production" images (e.g. created by a tag build and used in production): if an AMI tagged as "production" is older than 1 year, then 🗑️
    • Rationale: 1 year is a laaaaaareg margin to really ensure that we clean things up. I personnaly would try a "3 months" rules so if we do not update an AMI soemwhere, then we'll see it fail in 3 month, but given the low amount of tagged images, no need to worry.

@dduportal
Copy link
Contributor

Addon: we also have to delete the snapshot along with AMI.

The AWS documentation at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/deregister-ami.html describe the process: when you want to "delete an AMI", it's a 4 steps task:

  1. Get the AMI ID (already done by our script)
  2. Get the snapshot ID associated with this AMI
  3. Deregister the AMI (already done by our script)
  4. Delete the snapshot

@dduportal
Copy link
Contributor

@dduportal
Copy link
Contributor

dduportal commented Apr 12, 2023

@dduportal
Copy link
Contributor

Manually deregistered the folloiwng AMIs:

=> we're down to 72 AMIs (instead of 3000s).

Time to clean up the snapshots now!

@dduportal
Copy link
Contributor

@dduportal
Copy link
Contributor

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

No branches or pull requests

3 participants