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(cli): IAM Policy changes not deploying with --hotswap-fallback #28185

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Nov 29, 2023

The hotswappable resource detectors failed to correctly identify AWS::IAM::Policy resources as not-hotswappable.

When --hotswap-fallback was used and the only change to the stack was with AWS::IAM::Policy, this caused the deploy command to first report IAM changes, and then report no changes on the stack.

image

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

@github-actions github-actions bot added the p2 label Nov 29, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team November 29, 2023 11:05
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 29, 2023
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 Nov 29, 2023
@mrgrain mrgrain force-pushed the mrgrain/fix/iam-policy-ignored-in-hotswap branch from c1543ff to aca2ec8 Compare November 29, 2023 14:01
@mrgrain mrgrain force-pushed the mrgrain/fix/iam-policy-ignored-in-hotswap branch from aca2ec8 to d61a1fc Compare November 29, 2023 14:18
Comment on lines +621 to +640
const deploymentLambda2Old = {
Type: 'AWS::Lambda::Function',
Role: {
'Fn::GetAtt': [
'ServiceRole',
'Arn',
],
},
};

const deploymentLambda2New = {
Type: 'AWS::Lambda::Function',
Role: {
'Fn::GetAtt': [
'ServiceRole2',
'Arn',
],
},
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this existing test was unintentionally relying on undefined behavior.

Previously, the stack under would receive a change that changes Policy2 from being a policy that is used exclusively by S3Deployment, to a "free-floating" policy. This was because policy2Old -> policy2New is changing the role from ServiceRole -> ServiceRole2. However ServiceRole2 is not used by the S3Deployment.

Without adjusting the test case, it now would have failed because this new "free-floating" policy would have been detected as non-hotswappable and also not skippable since it is not connected to an S3Deployment anymore.
I believe the intent of the test was to test the skipping (based on test case description and assertions) and this accidentally worked. So I adjusted the test case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

@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.

@mrgrain mrgrain added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Nov 29, 2023
@aws-cdk-automation aws-cdk-automation removed the pr/needs-cli-test-run This PR needs CLI tests run against it. label Nov 29, 2023
@mrgrain mrgrain added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Nov 29, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review November 29, 2023 16:11

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 29, 2023
Comment on lines +621 to +640
const deploymentLambda2Old = {
Type: 'AWS::Lambda::Function',
Role: {
'Fn::GetAtt': [
'ServiceRole',
'Arn',
],
},
};

const deploymentLambda2New = {
Type: 'AWS::Lambda::Function',
Role: {
'Fn::GetAtt': [
'ServiceRole2',
'Arn',
],
},
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

mergify bot commented Nov 29, 2023

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).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 29, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 116b933 into main Nov 30, 2023
1 of 2 checks passed
@mergify mergify bot deleted the mrgrain/fix/iam-policy-ignored-in-hotswap branch November 30, 2023 00:24
Copy link
Contributor

mergify bot commented Nov 30, 2023

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).

chenjane-dev pushed a commit to chenjane-dev/aws-cdk that referenced this pull request Dec 5, 2023
…ws#28185)

The hotswappable resource detectors failed to correctly identify `AWS::IAM::Policy` resources as not-hotswappable.

When `--hotswap-fallback` was used and the only change to the stack was with `AWS::IAM::Policy`, this caused the deploy command to first report IAM changes, and then report `no changes` on the stack.

<img width="1076" alt="image" src="https://github.com/aws/aws-cdk/assets/379814/d77320bc-fc8d-4b70-b710-2c28467d07e5">

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2 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.

3 participants