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

fix(core): file asset publishing role not used in cdk diff to upload large templates #31597

Merged
merged 14 commits into from
Oct 3, 2024

Conversation

sumupitchayan
Copy link
Contributor

@sumupitchayan sumupitchayan commented Sep 30, 2024

Closes #29936

Reason for this change

When running cdk diff on larger templates, the CDK needs to upload the diff template to S3 to create the ChangeSet. However, the CLI is currently not using the the file asset publishing role to do so and is instead using the IAM user/role that is configured by the user in the CLI - this means that if the user/role lacks S3 permissions then the AccessDenied error is thrown and users cannot see a full diff.

Description of changes

This PR ensures that the FileAssetPublishingRole is used by cdk diff to upload assets to S3 before creating a ChangeSet by:

  • Deleting the makeBodyParameterAndUpload function which was using the deprecated publishAssets function from deployments.ts
  • Building and Publishing the template file assets inside the uploadBodyParameterAndCreateChangeSet function within cloudformation.ts instead

Description of how you validated changes

Integ test that deploys a simple CDK app with a single IAM role, then runs cdk diff on a large template change adding 200 IAM roles. I asserted that the logs did not contain the S3 access denied permissions errors, and also contained a statement for assuming the file publishing role. Reused the CDK app for the integ test from this PR by @sakurai-ryo which tried fixing this issue by adding another Bootstrap role (which we decided against).

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…e bug

Signed-off-by: Sumu <sumughan@amazon.com>
…sets in uploadBodyParameterAndCreateChangeSet in cloudformation.ts to fix bug

Signed-off-by: Sumu <sumughan@amazon.com>
…plate is published succesffuly

Signed-off-by: Sumu <sumughan@amazon.com>
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Sep 30, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team September 30, 2024 16:03
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Sep 30, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Sep 30, 2024
@sumupitchayan sumupitchayan changed the title fix(core): file asset publishing role not used in cdk diff to upload large diff templates fix(core): file asset publishing role not used in cdk diff to upload large templates Sep 30, 2024
Signed-off-by: Sumu <sumughan@amazon.com>
@sumupitchayan sumupitchayan marked this pull request as ready for review September 30, 2024 16:40
@rix0rrr
Copy link
Contributor

rix0rrr commented Oct 1, 2024

Deleting the broken makeBodyParameterAndUpload function which wasn't actually uploading anything to S3.

This is not a correct statement. It definitely was uploading things to S3.

Co-authored-by: Rico Hermans <rix0rrr@gmail.com>
Signed-off-by: Sumu <sumughan@amazon.com>
@sumupitchayan sumupitchayan added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Oct 2, 2024
@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: e0dc88c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sumupitchayan sumupitchayan added pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested and removed pr/needs-cli-test-run This PR needs CLI tests run against it. labels Oct 3, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review October 3, 2024 13:00

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Copy link
Contributor

mergify bot commented Oct 3, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit be1207b into main Oct 3, 2024
17 of 19 checks passed
@mergify mergify bot deleted the sumughan/diff-file-asset-publishing-role-not-used branch October 3, 2024 13:02
Copy link

github-actions bot commented Oct 3, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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