You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow up to #31611 which introduced S3 Asset Garbage Collection
## ECR Asset Garbage Collection
`cdk gc` now collects ECR assets.
```bash
cdk gc aws://0123456789012/us-east-1 \
--unstable='gc' \
--type='ecr'
```
or
```bash
cdk gc aws://0123456789012/us-east-1 \
--unstable='gc' \
--type='all'
```
all other options are duplicated from s3.
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy file name to clipboardExpand all lines: packages/aws-cdk/README.md
+20-11
Original file line number
Diff line number
Diff line change
@@ -896,28 +896,37 @@ CDK Garbage Collection.
896
896
897
897
> [!CAUTION]
898
898
> CDK Garbage Collection is under development and therefore must be opted in via the `--unstable` flag: `cdk gc --unstable=gc`.
899
-
>
900
-
> [!WARNING]
901
-
> `cdk gc` currently only supports garbage collecting S3 Assets. You must specify `cdk gc --unstable=gc --type=s3` as ECR asset garbage collection has not yet been implemented.
902
899
903
-
`cdk gc` garbage collects unused S3 assets from your bootstrap bucket via the following mechanism:
900
+
`cdk gc` garbage collects unused assets from your bootstrap bucket via the following mechanism:
904
901
905
902
- for each object in the bootstrap S3 Bucket, check to see if it is referenced in any existing CloudFormation templates
906
903
- if not, it is treated as unused and gc will either tag it or delete it, depending on your configuration.
907
904
905
+
The high-level mechanism works identically for unused assets in bootstrapped ECR Repositories.
906
+
908
907
The most basic usage looks like this:
909
908
909
+
```console
910
+
cdk gc --unstable=gc
911
+
```
912
+
913
+
This will garbage collect all unused assets in all environments of the existing CDK App.
914
+
915
+
To specify one type of asset, use the `type` option (options are `all`, `s3`, `ecr`):
916
+
910
917
```console
911
918
cdk gc --unstable=gc --type=s3
912
919
```
913
920
914
-
This will garbage collect S3 assets from the current bootstrapped environment(s) and immediately delete them. Note that, since the default bootstrap S3 Bucket is versioned, object deletion will be handled by the lifecycle
921
+
Otherwise `cdk gc` defaults to collecting assets in both the bootstrapped S3 Bucket and ECR Repository.
922
+
923
+
`cdk gc` will garbage collect S3 and ECR assets from the current bootstrapped environment(s) and immediately delete them. Note that, since the default bootstrap S3 Bucket is versioned, object deletion will be handled by the lifecycle
915
924
policy on the bucket.
916
925
917
926
Before we begin to delete your assets, you will be prompted:
918
927
919
928
```console
920
-
cdk gc --unstable=gc --type=s3
929
+
cdk gc --unstable=gc
921
930
922
931
Found X objects to delete based off of the following criteria:
923
932
- objects have been isolated for > 0 days
@@ -926,11 +935,11 @@ Found X objects to delete based off of the following criteria:
926
935
Delete this batch (yes/no/delete-all)?
927
936
```
928
937
929
-
Since it's quite possible that the bootstrap bucket has many objects, we work in batches of 1000 objects. To skip the
930
-
prompt either reply with `delete-all`, or use the `--confirm=false` option.
938
+
Since it's quite possible that the bootstrap bucket has many objects, we work in batches of 1000 objects or 100 images.
939
+
To skip the prompt either reply with `delete-all`, or use the `--confirm=false` option.
931
940
932
941
```console
933
-
cdk gc --unstable=gc --type=s3 --confirm=false
942
+
cdk gc --unstable=gc --confirm=false
934
943
```
935
944
936
945
If you are concerned about deleting assets too aggressively, there are multiple levers you can configure:
@@ -946,7 +955,7 @@ When using `created-buffer-days`, we simply filter out any assets that have not
0 commit comments