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

Error: The stack named CDKToolkit failed to deploy: CREATE_FAILED (Deployment failed) #57

Closed
pupeno opened this issue Jan 20, 2022 · 4 comments

Comments

@pupeno
Copy link

pupeno commented Jan 20, 2022

There are a few bugs opened around this error, but they all seem to be older and for previous versions. In my case, I'm running cdklocal bootstrap and this is the result:

PS C:\Users\pupeno\Code\example4-be> cdklocal bootstrap
 ⏳  Bootstrapping environment aws://000000000000/us-east-1...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
Using default execution policy of 'arn:aws:iam::aws:policy/AdministratorAccess'. Pass '--cloudformation-execution-policies' to customize.
CDKToolkit: creating CloudFormation changeset...
CDKToolkit |  0/14 | 22:19:42 | CREATE_IN_PROGRESS   | AWS::CloudFormation::Stack | CDKToolkit
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | TrustedAccounts
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | TrustedAccountsForLookup
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | CloudFormationExecutionPolicies
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | FileAssetsBucketKmsKeyId
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | PublicAccessBlockConfiguration
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | FileAssetsBucketName
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | ContainerAssetsRepositoryName
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | Qualifier
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | HasTrustedAccounts
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | HasTrustedAccountsForLookup
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | HasCloudFormationExecutionPolicies
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | HasCustomFileAssetsBucketName
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | CreateNewKey
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | UseAwsManagedKey
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | HasCustomContainerAssetsRepositoryName
CDKToolkit |  0/14 | 22:19:42 | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack | UsePublicAccessBlockConfiguration
CDKToolkit |  1/14 | 22:19:43 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | FileAssetsBucketEncryptionKey
CDKToolkit |  2/14 | 22:19:43 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | FileAssetsBucketEncryptionKeyAlias
CDKToolkit |  3/14 | 22:19:45 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | StagingBucket
CDKToolkit |  4/14 | 22:19:45 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | StagingBucketPolicy
CDKToolkit |  5/14 | 22:19:45 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | ContainerAssetsRepository
CDKToolkit |  6/14 | 22:19:45 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | FilePublishingRole
CDKToolkit |  7/14 | 22:19:45 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | ImagePublishingRole
CDKToolkit |  8/14 | 22:19:45 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | LookupRole
CDKToolkit |  9/14 | 22:19:46 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | FilePublishingRoleDefaultPolicy
CDKToolkit | 10/14 | 22:19:47 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | CloudFormationExecutionRole
CDKToolkit | 11/14 | 22:19:47 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | CdkBootstrapVersion
CDKToolkit | 12/14 | 22:19:47 | CREATE_COMPLETE      | AWS::CloudFormation::Stack | DeploymentActionRole
CDKToolkit | 12/14 | 22:19:47 | CREATE_FAILED        | AWS::CloudFormation::Stack | CDKToolkit

Failed resources:
 ❌  Environment aws://000000000000/us-east-1 failed bootstrapping: Error: The stack named CDKToolkit failed to deploy: CREATE_FAILED (Deployment failed)
    at Object.waitForStackDeploy (C:\Users\pupeno\scoop\persist\nodejs14\bin\node_modules\aws-cdk\lib\api\util\cloudformation.ts:309:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at prepareAndExecuteChangeSet (C:\Users\pupeno\scoop\persist\nodejs14\bin\node_modules\aws-cdk\lib\api\deploy-stack.ts:357:26)
    at C:\Users\pupeno\scoop\persist\nodejs14\bin\node_modules\aws-cdk\lib\cdk-toolkit.ts:480:24
    at async Promise.all (index 0)
    at CdkToolkit.bootstrap (C:\Users\pupeno\scoop\persist\nodejs14\bin\node_modules\aws-cdk\lib\cdk-toolkit.ts:477:5)
    at initCommandLine (C:\Users\pupeno\scoop\persist\nodejs14\bin\node_modules\aws-cdk\bin\cdk.ts:267:9)
The stack named CDKToolkit failed to deploy: CREATE_FAILED (Deployment failed)
PS C:\Users\pupeno\Code\example4-be>

The log from the Docker container is:

Waiting for all LocalStack services to be ready
2022-01-20 22:16:35,456 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2022-01-20 22:16:35,459 INFO supervisord started with pid 14
2022-01-20 22:16:36,462 INFO spawned: 'infra' with pid 20
. .venv/bin/activate; LOCALSTACK_INFRA_PROCESS=1 exec bin/localstack start --host --no-banner
2022-01-20 22:16:37,472 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

LocalStack version: 0.13.3.3
LocalStack Docker container id: 2aff7cf11500
LocalStack build date: 2022-01-20
LocalStack build git hash: 7dab7b4d

Starting edge router (https port 4566)...
Ready.
[2022-01-20 22:16:38 +0000] [21] [INFO] Running on https://0.0.0.0:4566 (CTRL + C to quit)
2022-01-20T22:16:38.787:INFO:hypercorn.error: Running on https://0.0.0.0:4566 (CTRL + C to quit)
2022-01-20T22:18:14.454:INFO:bootstrap.py: Execution of "_load_service_plugin" took 2036.96ms
2022-01-20T22:18:14.551:INFO:localstack.services.infra: Starting mock CloudFormation service on http port 4566 ...
2022-01-20T22:18:15.053:INFO:bootstrap.py: Execution of "require" took 2635.78ms
2022-01-20T22:19:44.448:INFO:localstack.services.motoserver: starting moto server on http://0.0.0.0:52745
2022-01-20T22:19:44.449:INFO:localstack.services.infra: Starting mock S3 service on http port 4566 ...
2022-01-20T22:19:44.606:WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': {'Fn::If': ['HasCustomContainerAssetsRepositoryName', {'Fn::Sub': '${ContainerAssetsRepositoryName}'}, {'Fn::Sub': 'cdk-${Qualifier}-container-assets-${AWS::AccountId}-${AWS::Region}'}]}}}
2022-01-20T22:19:44.654:INFO:localstack.services.infra: Starting mock SSM service on http port 4566 ...
2022-01-20T22:19:44.948:INFO:bootstrap.py: Execution of "require" took 510.35ms
2022-01-20T22:19:45.309:WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1'}}
2022-01-20T22:19:45.309:WARNING:localstack.utils.cloudformation.template_deployer: Unable to deploy resource type "ECR::Repository": {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1'}}
2022-01-20T22:19:45.471:INFO:localstack.services.infra: Starting mock IAM service on http port 4566 ...
2022-01-20T22:19:46.525:WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1'}, 'PhysicalResourceId': None}
2022-01-20T22:19:47.291:INFO:localstack.services.infra: Starting mock Cloudwatch Events service on http port 4566 ...
2022-01-20T22:19:47.384:WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1'}, 'PhysicalResourceId': None}
2022-01-20T22:19:47.870:WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1'}, 'PhysicalResourceId': None}
2022-01-20T22:19:49.818:WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {'Type': 'AWS::ECR::Repository', 'LogicalResourceId': 'ContainerAssetsRepository', 'Properties': {'ImageScanningConfiguration': {'ScanOnPush': True}, 'RepositoryName': 'cdk-hnb659fds-container-assets-000000000000-us-east-1'}, 'PhysicalResourceId': None}

My versions:

PS C:\Users\pupeno\Code\example4-be> npm list -g --depth=0
C:\Users\pupeno\scoop\persist\nodejs14\bin
+-- [email protected]
+-- [email protected]
`-- [email protected]

PS C:\Users\pupeno\Code\example4-be> cdk --version
2.4.0 (build 993f14d)
PS C:\Users\pupeno\Code\example4-be> aws --version
aws-cli/2.4.12 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
PS C:\Users\pupeno\Code\example4-be>

Thank you.

@whummer
Copy link
Member

whummer commented Jan 21, 2022

Thanks for reporting @pupeno . This issue seems to be similar to #56 . Looks like this is an issue with the CloudFormation deployment in LocalStack itself, unrelated to the cdklocal script. For these types of issues, please check out our main Github repo instead: https://github.com/localstack/localstack . (However, please note that you appear to be using some advanced features like ECR repositories, which are currently only available in the Pro version of LocalStack.) Thanks!

@terokaisti
Copy link

terokaisti commented Feb 4, 2022

I think this relates to aws-cdk version 2.

Repro:

  1. sudo npm i -g aws-cdk installs the latest version (currently 2.10.0)
  2. cdklocal bootstrap

See localstack docker logs:

localstack.utils.server.http2_server.HTTPErrorResponse: failed to get service for ssm: service ssm is disabled

  1. Add ssm to the SERVICES list and restart the docker container
  2. cdklocal bootstrap

See localstack docker logs:

WARNING:localstack.utils.cloudformation.template_deployer: Unexpected resource type ECR::Repository when resolving references of resource ContainerAssetsRepository: {"Type": "AWS::ECR::Repository", "LogicalResourceId": "ContainerAssetsRepository", "Properties": {"ImageScanningConfiguration": {"ScanOnPush": true}, "RepositoryName": "cdk-hnb659fds-container-assets-000000000000-us-east-1"}, "PhysicalResourceId": null}. To find out if ECR::Repository is supported in LocalStack Pro, please check out our docs at https://docs.localstack.cloud/aws/cloudformation

Problem

Localstack Free version doesn't support ECR so you must upgrade to Pro-version if you want to use aws-cdk@2


Workaround for Free version

Use aws-sdk version 1

  1. npm i -g aws-sdk@1
  2. cdklocal boostrap

🎉

@dominikschubert
Copy link
Member

Community now also adds a (non-functional) ECR repository so bootstrapping should now work for both Community and PRO.

@zExcel
Copy link

zExcel commented May 4, 2022

It still doesn't seem to be working for me. I've tried using all the localstack versions starting from v0.14.2, but none seem to be able to run the example that @terokaisti made.

~/w/localstackTest> cdk --version; localstack --version
2.22.0 (build 1db4b16)
0.14.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants