-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
(core): file asset publishing role is not used while performing cdk diff with larger templates #29936
(core): file asset publishing role is not used while performing cdk diff with larger templates #29936
Comments
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
|
Apologies ! I have updated the issue with more detailed steps and stack trace @pahud ! |
I got the same issue after upgrading from 2.86.0 to 2.147.0 . |
I use the following additional permissions assigned to the identity executing the cdk commands as a workaround: [
{
"effect": "ALLOW",
"actions": [
"s3:GetBucketLocation",
"s3:ListBucket",
"s3:GetEncryptionConfiguration"
],
"resources": [
"arn:aws:s3:::cdk-assets-${account}-${region}"
]
},
{
"effect": "ALLOW",
"actions": [
"s3:PutObject",
"s3:GetObject"
],
"resources": [
"arn:aws:s3:::cdk-assets-${account}-${region}/*"
]
}
] |
OK I can reproduce this issue. Looks like it would roll back to the current CDK CLI execution principal with permission denied on getBucketLocation operation. aws-cdk/packages/cdk-assets/lib/private/handlers/files.ts Lines 68 to 69 in 0875ef9
Tested with CDK 2.148.0. |
@pahud I get this with 2.148.0, here is the output from
|
The workaround from @sfriedlizuehlke above works well, with one small change to the S3 bucket name pattern I used this (CDK/Python) iam.PolicyStatement(
actions=[
"s3:GetBucketLocation",
"s3:ListBucket",
"s3:GetEncryptionConfiguration",
],
resources=["arn:aws:s3:::cdk-*-assets-*"],
),
iam.PolicyStatement(
actions=["s3:GetObject", "s3:PutObject"],
resources=["arn:aws:s3:::cdk-*-assets-*/*"],
), |
@mrlikl you mention that the IAM user configured in your CLI does not have S3 permissions, but from your stack trace it looks like the CLI is assuming the CDK Deploy Role:
Can you confirm whether or not you changed S3 permissions in the Deploy Role or if you are using a custom bootstrap template? |
@mrlikl I am unable to reproduce this bug, so I am wondering if you are using a custom bootstrap template where you restricted permissions on any of the roles? I wrote a CLI integ test with the example you provided and created a sample app manually, I also created an IAM role that had no permissions for any Also want to note that the S3 permissions on your assumed IAM role when calling |
@sumupitchayan I am still able to reproduce the issue. Did a fresh bootstrap now and confirmed again that the below steps would reproduce the behavior.
verbose logs:
The diff will show the difference, but the change set type diff creation fails. Adding Internal TT: P126676177 |
The FilePublishingRole already has the permission for the failing s3 call, so instead of deploy role shouldn't the file asset publishing role be used here ? |
@mrlikl nevermind yes you are right, I was able to reproduce the issue. Will put out a PR fix soon. |
Comments on closed issues and PRs are hard for our team to see. |
1 similar comment
Comments on closed issues and PRs are hard for our team to see. |
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
Create IAM user or role with deny all S3 actions.
Configure your CLI with the above role/user.
Create a CDK project with one SQS queue
Deploy
Add more resources that will create a larger template to the stack and execute
cdk diff -v
Stack trace -
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
The text was updated successfully, but these errors were encountered: