CDK Bootstrap: Failure bootstrapping due to Arn attribute for AWS::ECR::Repository
Whenever trying to bootstrap a CDK app, the bootstrap operations fails when it tries to update the ImagePublishingRoleDefaultPolicy, due to being unable to retrieve Arn attribute for AWS::ECR::Repository (which I'm not using in my CDK App at all).

2:47:45 PM | UPDATE_FAILED | AWS::IAM::Policy | ImagePublishingRoleDefaultPolicy
Unable to retrieve Arn attribute for AWS::ECR::Repository, with error message null
2:47:47 PM | UPDATE_ROLLBACK_IN_P | AWS::CloudFormation::Stack | CDKToolkit
The following resource(s) failed to create: [LookupRole]. The following resource(s) failed to update: [ImagePublishingR
oleDefaultPolicy, StagingBucket].
Reproduction Steps
Create a new CDK app with Pipelines (not sure if is Pipelines causing the problem, but that's what I'm trying) based on Python.
Run cdk bootstrap, to see it fail (even with --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess set).
What did you expect to happen?
For the app to be bootstrapped.
What actually happened?
The CDKToolkit stack fails to deploy, blocking me from deploying other apps.

Environment
- CDK CLI Version : 1.124.0 (build 65761fe)
- Framework Version:
- Node.js Version: v14.5.0
- OS : MacOS 11.5.2
- Language (Version): Python 3.9.5
Other
I stumbled upon this issue when trying to reproduce (in Python) the blog post about AWS CDK Pipelines
Localstack has had a similar issue which they solved by updating their Docker image.
This is :bug: Bug Report
Solved by deleting the CDKToolkit stack from CloudFormation, then launching again the cdk bootstrap. Closing, feel free to reopen if you need more info.
⚠️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.
This is happening in our project now with the latest cdk version.
failed bootstrapping: Error: The stack named CDKToolkit failed to deploy: UPDATE_ROLLBACK_COMPLETE: Unable to retrieve Arn attribute for AWS::ECR::Repository, with error message null
I can not delete the CDKToolkit because my production environment is running on top of it.
Should I create a new issue?
UPDATE: I just created manually the expected repository and it finally updated. Will leave my comment to help someone with the same issue in the future.
@AndreAlves3 coming in clutch 👏🏻 ty
In case this helps someone, this can also happen if you've accidentally deleted an ECR repo implicitly/explicitly created by the Stack you are deploying (not CDKToolKit).
Solution is the same - either tear down the Stack you're trying to deploy and then redeploy, or recreate the expected ECR repo manually.
I encountered same issue when using AWS Amplify. Making the private ECR repository named cdk-hnb659fds-container-assets-[account ID]-[region] manually worked for me.
I encountered same issue when using AWS Amplify. Making the private ECR repository named
cdk-hnb659fds-container-assets-[account ID]-[region]manually worked for me.
Great observation @tttol and I think you almost finished the puzzle. Recently I was deleting old resources and I think I deleted some random ECR I never used and don't remember having ever created in the first place. That ECR must've been generated while CDK bootstrapping my account and I never noticed it and just deleted it manually. So your solution should work, but I wanted mine a tiny bit cleaner so I just deleted the entire CDK stack from cloudformation, I left the ECR deleted (so the CDK bootstrap would generate it for me again), and I fully deleted the CKD bootstrap S3 bucket that was leftover from previous CDK bootstrap. After doing all of this and then running CDK bootstrap for my account-id/region again it successfully bootstrapped and then I clicked build new app using my existing Github Repository that was just forked off the NextJS Amplify template repo using just default options for everything and Amplify Gen 2 created the new application with zero issues.
This was very frustrating, but it kind of does make sense why this issue is happening in this manner. Once again thank you @tttol for your help and hopefully this solution resolves this issue for anybody else if you are experiencing it in this way. Basically what @dgallitelli did works, but the way I'm describing it is for if you have extra issues and need more in-depth explanation.
Quick solution in my case was to:
- Delete the CDKToolkit stack then
- Manually delete the cdk-related buckets in S3 (these were not automatically removed by the stack deletion). The CDK bootstrap ran successfully without any errors.