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

Incorrect Bootstrap Warning #28888

Closed
Joe-Zer0 opened this issue Jan 26, 2024 · 2 comments · Fixed by #29938, rwlxxvii/containers#124 or rwlxxvii/containers#140 · May be fixed by NOUIY/aws-solutions-constructs#99 or NOUIY/aws-solutions-constructs#101
Assignees
Labels
bug This issue is a bug. effort/medium Medium work item – several days of effort effort/small Small work item – less than a day of effort p2 package/tools Related to AWS CDK Tools or CLI

Comments

@Joe-Zer0
Copy link

Describe the bug

Running cdk diff with a profile that does not have permission to assume cdk-<guid>-deploy-role causes the warning (To get rid of this warning, please upgrade to bootstrap version >= 8) to be displayed.

Running cdk diff with a profile that can assume cdk-<guid>-deploy-role does not display the warning.
The account is bootstrapped with the latest version (20 currently).

This warning is dumped to the logs twice, once before and after the diff results are displayed.
Before:

[time] Assuming role 'arn:aws:iam::XXXXX:role/cdk-<guid>-lookup-role-XXXXX-us-east-1'.
[time] Assuming role failed: User: arn:aws:sts::XXXXX:assumed-role/Dev_Team_Role/aws-sdk-js-1706295393223 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::XXXXX:role/cdk-<guid>-lookup-role-XXXXX-us-east-1
[time] Could not assume role in target account using current credentials User: arn:aws:sts::XXXXX:assumed-role/Dev_Team_Role/aws-sdk-js-1706295393223 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::XXXXX:role/cdk-<guid>-lookup-role-XXXXX-us-east-1 . Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
current credentials could not be used to assume 'arn:aws:iam::XXXXX:role/cdk-<guid>-lookup-role-XXXXX-us-east-1', but are for the right account. Proceeding anyway.
(To get rid of this warning, please upgrade to bootstrap version >= 8)

After:

[time] Retrieved account ID XXXXX from disk cache
(To get rid of this warning, please upgrade to bootstrap version >= 8)
[time] Retrieved account ID XXXXX from disk cache
[time] Retrieved account ID XXXXX from disk cache
[time] Assuming role 'arn:aws:iam::XXXXX:role/cdk-<guid>-deploy-role-XXXXX-us-east-1'.
[time] Assuming role failed: User: arn:aws:sts::XXXXX:assumed-role/Dev_Team_Role/aws-sdk-js-1706295393223 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::XXXXX:role/cdk-<guid>-deploy-role-XXXXX-us-east-1
[time] Could not assume role in target account using current credentials User: arn:aws:sts::XXXXX:assumed-role/Dev_Team_Role/aws-sdk-js-1706295393223 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::XXXXX:role/cdk-<guid>-deploy-role-XXXXX-us-east-1 . Please make sure that this role exists in the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.
current credentials could not be used to assume 'arn:aws:iam::XXXXX:role/cdk-<guid>-deploy-role-XXXXX-us-east-1', but are for the right account. Proceeding anyway.

We do not want the dev teams to directly deploy outside of the CI/CD pipeline. So they are correctly prevented from assuming the cdk deploy role. But we do want them to be able to run a diff. This warning however, is causing confusion. I'm also confused as to why it mentions bootstrap version 8. Seeing as the stack was deployed on version 19 and we are currently on version 20.

Expected Behavior

I expect to not get this warning message: (To get rid of this warning, please upgrade to bootstrap version >= 8).

Current Behavior

It currently displays this warning message: (To get rid of this warning, please upgrade to bootstrap version >= 8).

Reproduction Steps

Run a cdk diff using a profile that does not have permission to assume cdk-<guid>-deploy-role.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.123.0 (build a594112)

Framework Version

No response

Node.js Version

v20.10.0

OS

Windows 10

Language

Python

Language Version

Python 3.12.1

Other information

No response

@Joe-Zer0 Joe-Zer0 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 26, 2024
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jan 26, 2024
@pahud pahud added p2 effort/medium Medium work item – several days of effort labels Jan 29, 2024
@pahud
Copy link
Contributor

pahud commented Jan 29, 2024

Yes that could be a little bit confusing.

@pahud pahud added effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 29, 2024
@vinayak-kukreja vinayak-kukreja self-assigned this Apr 22, 2024
@mergify mergify bot closed this as completed in #29938 Apr 26, 2024
mergify bot pushed a commit that referenced this issue Apr 26, 2024
…ion exceeds the recommended version (#29938)

Closes #28888

### Reason for this change

Currently, we just check for if a minimum bootstrap version is needed for a functionality and give a warning. But, we do not check the bootstrap version of the stack itself. This gives a confusing warning for upgrading to a bootstrap version (example: version 8) when the stack bootstrap version is already higher than the recommended version.

### Description of changes

We cannot know successfully what the bootstrap version is in the AWS account without the lookup role. We are getting this warning while trying to assume the lookup role and failing to assume it. 

I am removing upgrade related warnings since we are emitting them without any confirmation of the user's account bootstrap version. This will lead to confusion. Instead, I am trying to make some of the existing error messages more clear.

### Description of how you validated changes

Updated unit tests. 
Will run this through test pipeline.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

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

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment