aws-cloudformation / aws-cloudformation/cloudformation-coverage-roadmap
AWS::ECR::Repository- [BUG] - EmptyOnDelete does not work in CloudControl API
- Dominant language
- No language data
- Stars
- 1.1k
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
### Name of the resource
AWS::ECR::Repository
### Resource Name
_No response_
### Issue Description
[EmptyOnDelete](https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/515) was added to CloudFormation, but it doesn't work in CloudControl.
### Expected Behavior
I would expect for a repository with `EmptyOnDelete=true` to be successfully deleted when it contains images.
### Observed Behavior
The delete fails with
```
The repository with name 'testrepository' in registry with id '111111111111' cannot be deleted because it still contains images
```
### Test Cases
Step1 - Create a repository with `EmptyOnDelete=true`
```console
$ aws cloudcontrol create-resource \
--type-name AWS::ECR::Repository \
--desired-state "{\"EmptyOnDelete\": true, \"RepositoryName\": \"testrepository\"}"
```
Step2 - Push an image
```console
$ export AWS_REGION=us-east-2
$ export AWS_ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text)
$ aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com docker pull alpine:latest
$ docker tag alpine:latest $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/testrepository:latest
$ docker push $AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/testrepository:latest
```
Step3 - Delete resource
```console
$ aws cloudcontrol delete-resource --identifier testrepository --type-name 'AWS::ECR::Repository'
```
Step4 - Look for error message
```console
$ aws cloudcontrol list-resource-requests --resource-request-status-filter Operations=DELETE,OperationStatuses=FAILED --query 'ResourceRequestStatusSummaries[?Identifier==`testrepository`]'
```
### Other Details
_No response_
Contributor guide
Research direction
Start with the AWS CloudControl API create-resource and delete-resource commands for AWS::ECR::Repository, then reproduce the failure by pushing an image with Docker. Compare the EmptyOnDelete=true request with the failed delete-resource result; done means a populated repository is deleted successfully through CloudControl API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100