- Newest
- Most votes
- Most comments
AWS CodeArtifact does not currently offer built-in automated cleanup functionality for old or obsolete artifacts. The primary methods for deleting packages and package versions in CodeArtifact are indeed through the AWS CLI or the AWS Management Console, as you've found in the documentation.
However, you can create a custom solution to automate the cleanup process using AWS services. Here's an approach you could consider:
-
Use AWS Lambda to create a function that executes the necessary AWS CLI commands to delete old packages or package versions.
-
Schedule this Lambda function using Amazon EventBridge (formerly CloudWatch Events) to run at your desired intervals, mimicking your current scheduled tasks.
-
The Lambda function can use the
delete-packageordelete-package-versionsCLI commands to remove old artifacts based on your defined criteria (e.g., age, version number, or other metadata). -
You can also use the
DisposePackageVersionsAPI, which deletes the assets in package versions and sets their status to 'Disposed'. This is particularly useful for permanent deletion, as disposed package versions cannot be restored. -
To identify which packages to delete, you can use the
ListPackageVersionsAPI to get a list of all package versions, potentially filtering by status.
While this approach requires some initial setup, it allows you to customize the cleanup process to your specific needs and automate it in a way that's similar to your current locally-hosted solution.
Remember to thoroughly test any automated deletion scripts in a non-production environment first, as deleting packages or versions in CodeArtifact is a permanent action and cannot be undone.
Sources
Delete a package or package version - CodeArtifact
DisposePackageVersions - AWS CodeArtifact
Relevant content
asked 5 years ago
asked a year ago
asked a year ago
