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

(core): file asset publishing role is not used while performing cdk diff with larger templates #29936

Open
mrlikl opened this issue Apr 23, 2024 · 2 comments
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@mrlikl
Copy link
Contributor

mrlikl commented Apr 23, 2024

Describe the bug

cdk diff is not using file asset publish role when uploading larger templates to S3 while creating the change set. It is using the user/role that is configured in the CLI. If the user/role (configured in CLI) lacks permissions then AccessDenied error is thrown and fallback to template differences.

Expected Behavior

File asset publish role to be used to upload templates for cdk diff

Current Behavior

fail: Access Denied
Failed to publish one or more assets. See the error messages above for more information.

Reproduction Steps

  1. Create IAM user or role with deny all S3 actions.

  2. Configure your CLI with the above role/user.

  3. Create a CDK project with one SQS queue

// create a stack with one sqs queue
new sqs.Queue(this, `Queue`, {});
  1. Deploy

  2. Add more resources that will create a larger template to the stack and execute cdk diff -v

// add 300 more sqs queue's to the same stack and perform cdk diff -v
for (let i = 0; i < 300; i++) {
      new sqs.Queue(this, `Queue${i}`, {
      });
    }   

Stack trace -

Stack CdktsStack
[23:46:13] Retrieved account ID xxxxxxxxxxxx from disk cache
[23:46:13] Assuming role 'arn:aws:iam::xxxxxxxxxxxx:role/cdk-hnb659fds-lookup-role-xxxxxxxxxxxx-us-east-1'.
[23:46:18] Retrieved account ID xxxxxxxxxxxx from disk cache
[23:46:20] Retrieved account ID xxxxxxxxxxxx from disk cache
[23:46:20] Assuming role 'arn:aws:iam::xxxxxxxxxxxx:role/cdk-hnb659fds-deploy-role-xxxxxxxxxxxx-us-east-1'.
[23:46:21] Waiting for stack CDKToolkit to finish creating or updating...
[23:46:22] Storing template in S3 at: https://cdk-hnb659fds-assets-xxxxxxxxxxxx-us-east-1.s3.us-east-1.amazonaws.com/cdk/CdktsStack/e6cbc1ec64bd0bf5f83ee188026e9c010633551b8252f036384f6dddb29932f0.yml
[23:46:22] [0%] start: Publishing e6cbc1ec64bd0bf5f83ee188026e9c010633551b8252f036384f6dddb29932f0:current
[23:46:23] [0%] check: Check s3://cdk-hnb659fds-assets-xxxxxxxxxxxx-us-east-1/cdk/CdktsStack/e6cbc1ec64bd0bf5f83ee188026e9c010633551b8252f036384f6dddb29932f0.yml
[23:46:32] [0%] upload: Upload s3://cdk-hnb659fds-assets-xxxxxxxxxxxx-us-east-1/cdk/CdktsStack/e6cbc1ec64bd0bf5f83ee188026e9c010633551b8252f036384f6dddb29932f0.yml
[100%] fail: Access Denied
[23:46:36] Failed to publish one or more assets. See the error messages above for more information.
Could not create a change set, will base the diff on template differences (run again with -v to see the reason)

The IAM user configured in my CLI does not have S3 permissions.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.138.0

Framework Version

No response

Node.js Version

20.10

OS

macos

Language

TypeScript

Language Version

No response

Other information

No response

@mrlikl mrlikl added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 23, 2024
@github-actions github-actions bot added the @aws-cdk/core Related to core CDK functionality label Apr 23, 2024
@pahud pahud self-assigned this Apr 23, 2024
@pahud
Copy link
Contributor

pahud commented Apr 23, 2024

I am not sure if I get it correct.

Can you elaborate about the steps with some real code snippets or commands and share the full error message when you cdk diff -v?

Reproduction Steps
Create IAM user or role with deny all S3 actions.

Configure an environment with the role/user

@pahud pahud removed their assignment Apr 23, 2024
@pahud pahud added p2 effort/medium Medium work item – several days of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 23, 2024
@mrlikl
Copy link
Contributor Author

mrlikl commented Apr 24, 2024

Apologies ! I have updated the issue with more detailed steps and stack trace @pahud !

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants