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

AWS::ECR::Repository- [BUG] - EmptyOnDelete does not work in CloudControl API #2046

Open
corymhall opened this issue May 17, 2024 · 1 comment

Comments

@corymhall
Copy link

Name of the resource

AWS::ECR::Repository

Resource Name

No response

Issue Description

EmptyOnDelete 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

$ aws cloudcontrol create-resource \
    --type-name AWS::ECR::Repository \
    --desired-state "{\"EmptyOnDelete\": true, \"RepositoryName\": \"testrepository\"}"

Step2 - Push an image

$ 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

$ aws cloudcontrol delete-resource --identifier testrepository --type-name 'AWS::ECR::Repository'

Step4 - Look for error message

$ aws cloudcontrol list-resource-requests  --resource-request-status-filter Operations=DELETE,OperationStatuses=FAILED --query 'ResourceRequestStatusSummaries[?Identifier==`testrepository`]'

Other Details

No response

@yanmjy
Copy link

yanmjy commented Jun 10, 2024

Hey, this is a known issue for CloudFormation. The fix is in the road map and coming soon. Before the fix coming in, we suggest customers to do two-step approach for delete. That is, delete the contents of ECR Repository first and then invoke delete using CCAPI.

Please let me know if you have any other questions. Thanks!

@nmeisen nmeisen moved this from Coming Soon to Shipped in coverage-roadmap Jun 10, 2024
@nmeisen nmeisen moved this from Shipped to Coming Soon in coverage-roadmap Jun 10, 2024
@cfn-github-issues-bot cfn-github-issues-bot moved this from Coming Soon to Researching in coverage-roadmap Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
coverage-roadmap
  
Researching
Development

No branches or pull requests

2 participants