aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

CDK Bootstrap: Failure bootstrapping due to Arn attribute for AWS::ECR::Repository

Open dgallitelli opened this issue 5 years ago • 8 comments

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).

image

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.

image

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

dgallitelli avatar Sep 22 '21 12:09 dgallitelli

Solved by deleting the CDKToolkit stack from CloudFormation, then launching again the cdk bootstrap. Closing, feel free to reopen if you need more info.

dgallitelli avatar Sep 22 '21 15:09 dgallitelli

⚠️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.

github-actions[bot] avatar Sep 22 '21 15:09 github-actions[bot]

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 avatar Sep 26 '24 08:09 AndreAlves3

@AndreAlves3 coming in clutch 👏🏻 ty

pitayapj avatar Nov 01 '24 06:11 pitayapj

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.

BwL1289 avatar Jan 05 '25 22:01 BwL1289

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.

tttol avatar Jan 15 '25 21:01 tttol

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.

jhorvat7 avatar Jan 20 '25 18:01 jhorvat7

Quick solution in my case was to:

  1. Delete the CDKToolkit stack then
  2. 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.

jrothman avatar Jan 25 '25 08:01 jrothman