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

Bootstrap bucket/ECR repository garbage collector #11071

Closed
markcarroll opened this issue Oct 23, 2020 · 13 comments
Closed

Bootstrap bucket/ECR repository garbage collector #11071

markcarroll opened this issue Oct 23, 2020 · 13 comments
Labels
@aws-cdk/aws-ecr Related to Amazon Elastic Container Registry @aws-cdk/core Related to core CDK functionality effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p1 package/tools Related to AWS CDK Tools or CLI

Comments

@markcarroll
Copy link

markcarroll commented Oct 23, 2020

Our CDK Bootstrap staging bucket on S3 now has gigabytes of assets in there, most of which are either old versions of current stacks, or for stacks that have long since been deleted.

How do we go about cleaning these up?

Does the CDK have any capability to clean up out of date or no longer needed assets? If not, it seems like it should. This is starting to incur noticeable costs for us.

@markcarroll markcarroll added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Oct 23, 2020
@arpowers
Copy link

just run a rm -rf at some point in your lifecycle.

@markcarroll
Copy link
Author

on the S3 staging bucket? My understanding is that the asset files are referred to by CloudFormation.

@arpowers
Copy link

Ah I thought you were talking about cdk.out... guessing this is in cdk/pipeline?

@hoegertn
Copy link
Contributor

I think markcarroll is talking about the cdk bootstrap bucket that holds the assets.

@markcarroll markcarroll changed the title CDK Staging Bucket full of garbage - how to clean? CDK Bootstrap Staging Bucket full of garbage - how to clean? Oct 23, 2020
@markcarroll
Copy link
Author

correct. thanks for the terminology correction, I have updated my question to clarify.

@SomayaB SomayaB added @aws-cdk/core Related to core CDK functionality package/tools Related to AWS CDK Tools or CLI labels Oct 27, 2020
@SomayaB
Copy link
Contributor

SomayaB commented Oct 27, 2020

Related to #986

@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 2, 2020

Looks like we don't yet have a feature request for the Assets garbage collector. Repurposing this.

The unfortunate answer is that we currently don't have a good solution for you.

@rix0rrr rix0rrr changed the title CDK Bootstrap Staging Bucket full of garbage - how to clean? Bootstrap bucket garbage collector Nov 2, 2020
@rix0rrr rix0rrr added effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p1 and removed guidance Question that needs advice or information. labels Nov 2, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Nov 2, 2020
@rix0rrr rix0rrr changed the title Bootstrap bucket garbage collector Bootstrap bucket/ECR repository garbage collector Mar 15, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ecr Related to Amazon Elastic Container Registry label Mar 15, 2021
@luxaritas
Copy link
Contributor

Per the above issue cross reference, this is a big issue for containers which can be individually multiple GBs

@elhedran
Copy link
Contributor

It seems to me this would be easier if you could have a 1-1 mapping of bootstrap stacks to deploy stacks - could then just delete any asset not deployed in this deployment upon success (cleanup), anything in the repo/s3 bucket that isn't part of the current list of assets from the stacksynth can go. Overly simplistic I know - but how much value is there by sharing the bootstrap stack across deployment stacks, because I'm not sure I see it?

As near as I can tell you could do it for ecr and s3 via tagging as well, (tag current on deploy, tag prior on cleanup) and have a lifecycle configured for the ecr/s3 based on tag - only the current IStackSynthesizer doesn't seem to be given access to the locations of the prior assets no longer used so couldn't change their tags. If it had two functions retireFileAsset(asset: FileAssetLocation) and retireDockerImageAsset(asset: DockerImageAssetLocation) it should be possible to implement garbage collection external to the cdk (e.g. custom stack-synth) - that is assuming that the cdk has some record of the prior stacks assets to do set operations on against the current stack assets.

@milesgranger
Copy link

It seems, propagating the tags for a given deployment to the ECR images and s3 assets would be enough for users to generate their own garbage collection.

We tag our deployments/assets using standard semantic versioning, and can 'easily' remove objects past a given version. However, it doesn't appear assets loaded into the bootstrap s3 bucket get the same tags as resources in the stack; which I find slightly weird. Please let me know if I've missed something here. :)

@gbvanrenswoude
Copy link

Decent attempt at keeping assets under control while AWS is working on this: https://github.com/jogold/cloudstructs/blob/master/src/toolkit-cleaner/README.md

@peterwoodworth
Copy link
Contributor

Thanks all for asking support for this feature, we're aware it's desired and have put in some progress towards implementing this. I'll be closing this however in favor of #6692 so we can keep discussion in one place

@github-actions
Copy link

github-actions bot commented Sep 7, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecr Related to Amazon Elastic Container Registry @aws-cdk/core Related to core CDK functionality effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests