localstack / aws-cdk-local

Thin wrapper script for using the AWS CDK CLI with LocalStack
Apache License 2.0
263 stars 17 forks source link

sample-app failes to create SNS listener #77

Closed deanbaker closed 1 year ago

deanbaker commented 1 year ago

Trying to get localstack and cdklocal working together on WSL Ubuntu. Following the instructions with the sample-app from your github, I get an error when creating the SNS subscription:

cdklocal bootstrap is successful:

 ⏳  Bootstrapping environment aws://000000000000/ap-southeast-2...
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...
 ✅  Environment aws://000000000000/ap-southeast-2 bootstrapped.

cdklocal deploy fails:

➜  test git:(master) ✗ cdklocal deploy

✨  Synthesis time: 1.1s

TestStack: building assets...

[0%] start: Building 88ad49c71a87e84166ac6e961b1dc01a3a6998e920348b10c0d4c04a8e49b0db:current_account-current_region
[100%] success: Built 88ad49c71a87e84166ac6e961b1dc01a3a6998e920348b10c0d4c04a8e49b0db:current_account-current_region

TestStack: assets built

This deployment will make potentially sensitive changes according to your current security approval level (--require-approval broadening).
Please confirm you intend to make the following modifications:

IAM Statement Changes
┌───┬──────────────────┬────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────────┐
│   │ Resource         │ Effect │ Action          │ Principal                 │ Condition                                        │
├───┼──────────────────┼────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────────┤
│ + │ ${TestQueue.Arn} │ Allow  │ sqs:SendMessage │ Service:sns.amazonaws.com │ "ArnEquals": {                                   │
│   │                  │        │                 │                           │   "aws:SourceArn": "${TestTopic}"                │
│   │                  │        │                 │                           │ }                                                │
└───┴──────────────────┴────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────────┘
(NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Do you wish to deploy these changes (y/n)? y
TestStack: deploying...
[0%] start: Publishing 88ad49c71a87e84166ac6e961b1dc01a3a6998e920348b10c0d4c04a8e49b0db:current_account-current_region
[100%] success: Published 88ad49c71a87e84166ac6e961b1dc01a3a6998e920348b10c0d4c04a8e49b0db:current_account-current_region
TestStack: creating CloudFormation changeset...

 ❌  TestStack failed: Error: The stack named TestStack failed to deploy: CREATE_FAILED (Deployment failed)
    at FullCloudFormationDeployment.monitorDeployment (/home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/aws-cdk/lib/api/deploy-stack.ts:505:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at deployStack2 (/home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:241:24)
    at /home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/aws-cdk/lib/deploy.ts:39:11
    at run (/home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/p-queue/dist/index.js:163:29)

 ❌ Deployment failed: Error: Stack Deployments Failed: Error: The stack named TestStack failed to deploy: CREATE_FAILED (Deployment failed)
    at deployStacks (/home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/aws-cdk/lib/deploy.ts:61:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at CdkToolkit.deploy (/home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/aws-cdk/lib/cdk-toolkit.ts:315:7)
    at initCommandLine (/home/dean/.nvm/versions/node/v16.14.2/lib/node_modules/aws-cdk/lib/cli.ts:358:12)

Stack Deployments Failed: Error: The stack named TestStack failed to deploy: CREATE_FAILED (Deployment failed)

When I remove the subscription from the stack by commenting out this line topic.addSubscription(new subs.SqsSubscription(queue)); I can see the stack has been created successfully - both sqs and sns have been created when I run awslocal sns list-topics and so on.

I can use awslocal to manually create a subscription, so I don't believe it is a problem there

whummer commented 1 year ago

Hi @deanbaker , thanks for reporting, and apologies for the very long delay. We haven't been able to replicate this issue - seems like the deployment of the CDK JavaScript sample app succeeds with the latest version:

$ cdklocal init sample-app --language=javascript
...
$ cdklocal bootstrap
...
$ cdklocal deploy
...
┌───┬──────────────────┬────────┬─────────────────┬───────────────────────────┬──────────────────────────────────────────────────┐
│   │ Resource         │ Effect │ Action          │ Principal                 │ Condition                                        │
├───┼──────────────────┼────────┼─────────────────┼───────────────────────────┼──────────────────────────────────────────────────┤
│ + │ ${TestQueue.Arn} │ Allow  │ sqs:SendMessage │ Service:sns.amazonaws.com │ "ArnEquals": {                                   │
│   │                  │        │                 │                           │   "aws:SourceArn": "${TestTopic}"                │
│   │                  │        │                 │                           │ }                                                │
└───┴──────────────────┴────────┴─────────────────┴───────────────────────────┴──────────────────────────────────────────────────┘
(NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Do you wish to deploy these changes (y/n)? y
TestStack: deploying... [1/1]
[0%] start: Publishing 5add20c85c5bcda32aaf9a438a244060ddaf872f9525711b9c7f67f8a61e8195:current_account-current_region
[100%] success: Published 5add20c85c5bcda32aaf9a438a244060ddaf872f9525711b9c7f67f8a61e8195:current_account-current_region
TestStack: creating CloudFormation changeset...

 ✅  TestStack

✨  Deployment time: 5.16s

Stack ARN:
arn:aws:cloudformation:eu-central-1:000000000000:stack/TestStack/ba3e4010

✨  Total time: 5.36s

Can you please pull the latest LocalStack Docker image, install the latest version of cdklocal, and give it another try? Thanks for your help!

whummer commented 1 year ago

Closing as resolved - please do let us know if the problem persists.. Thanks!