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

cdk cli: removing trust, needs --untrust flag and a clarification that this is safe #22703

Closed
microblag opened this issue Oct 30, 2022 · 7 comments · Fixed by #33091
Closed
Assignees
Labels
bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 package/tools Related to AWS CDK Tools or CLI

Comments

@microblag
Copy link

Describe the issue

I've had a look through the docs, and asked in the discussion section #22067 but unfortunatly didn't get an answer. I'm trying to find out how to remove a trust relationship from one account to another and if it's safe to do this with existing stacks that were using that trust relationship.

I assume editing the parameter in the cloudformation template for the bootstrap would remove the trust relationship but as this is a very manual type of thing to do I'm concerned what the implications might be.

Some documentation of either how to do this (if it's safe/possible) and the ramifications of doing so. Or alternativly, some documentation on this not being possilbe/safe as a caveat to the --trust docs so that users can be aware this is a non-reversable action.

Links

https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping.html

@microblag microblag added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Oct 30, 2022
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Oct 30, 2022
@peterwoodworth
Copy link
Contributor

Thanks for reporting this @microblag, this is an interesting problem.

As far as I can tell, there's no officially supported method to remove a trust relationship from a bootstrap stack. You can normally adjust the trust relationship by redeploying with cdk bootstrap --trust ... and adjusting the accounts you're deploying to, however there's not a clear way to redeploy without any trust because you need to pass in a value when you call the trust option. Since --trust asks for an array, we can pass in a comma as the trust value to indicate an empty array. So, running cdk bootstrap --trust , will eliminate the trust statements from your policies.

We should provide a cleaner option to remove the trust option, and also document this option so that users don't have to pass in a comma. Thanks again for reporting this!

@peterwoodworth peterwoodworth added p1 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 Nov 1, 2022
@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 5, 2023

So, running cdk bootstrap --trust , will eliminate the trust statements from your policies.

Are you sure that is true, and did you test this? Because that doesn't sound like an API I would design 😬.

--trust only impacts the AssumeRole policy of the roles in the bootstrap stack, so will prevent future AssumeRoles. It is safe to change the values in the CloudFormation console.

@rix0rrr
Copy link
Contributor

rix0rrr commented Jan 5, 2023

A cdk bootstrap --untrust operation might be helpful to assure people that this is safe to do.

@rix0rrr rix0rrr added feature-request A feature should be added or improved. p2 and removed p1 labels Jan 5, 2023
@rix0rrr rix0rrr removed their assignment Jan 5, 2023
@rix0rrr rix0rrr changed the title cdk cli: no documentation on removing cross account trust cdk cli: removing trust, needs --untrust flag and a clarification that this is safe Jan 5, 2023
@peterwoodworth
Copy link
Contributor

did you test this?

@rix0rrr I did test this! Though I think that's more a general CLI quirk than something that was intentionally designed for this project?

@HBobertz
Copy link
Contributor

HBobertz commented Nov 4, 2024

I'm inferring that rico wanted me to verify if cdk bootstrap --trust , actually works and I can confirm that it seems like it does

❯ cdk bootstrap --trust , --cloudformation-execution-policies arn:aws:iam::aws:policy/<policy_name>
current credentials could not be used to assume 'arn:aws:iam::<act_id>:role/cdk-<random_prefix>-lookup-role-<act_id>-us-east-2', but are for the right account. Proceeding anyway.
current credentials could not be used to assume 'arn:aws:iam:<act_id>:role/cdk-<random_prefix>-lookup-role-<act_id>-us-east-2', but are for the right account. Proceeding anyway.
 ⏳  Bootstrapping environment aws://<act_id>/us-east-2...
Trusted accounts for deployment: ,
Trusted accounts for lookup: (none)
Execution policies: arn:aws:iam::aws:policy/<policy_name>
CDKToolkit: creating CloudFormation changeset...
 ✅  Environment aws://<act_id>/us-east-2 bootstrapped.

And it did in fact create the stack so yeah, that works. We probably should still do --untrust though

@otaviomacedo otaviomacedo self-assigned this Jan 8, 2025
@jiayiwang7 jiayiwang7 added p1 bug This issue is a bug. and removed p2 labels Jan 8, 2025
@mergify mergify bot closed this as completed in #33091 Jan 23, 2025
@mergify mergify bot closed this as completed in 4713bdd Jan 23, 2025
Copy link

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.

1 similar comment
Copy link

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 Jan 23, 2025
moelasmar pushed a commit that referenced this issue Jan 24, 2025
Add a new option, `--untrust`, to the `bootstrap` command. Passing a list of account IDs as values to this option removes those account IDs from the trust relationships in the bootstrap roles.

Closes #22703.

----

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

(cherry picked from commit 4713bdd)
moelasmar pushed a commit that referenced this issue Jan 24, 2025
Add a new option, `--untrust`, to the `bootstrap` command. Passing a list of account IDs as values to this option removes those account IDs from the trust relationships in the bootstrap roles.

Closes #22703.

----

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

(cherry picked from commit 4713bdd)
moelasmar pushed a commit that referenced this issue Jan 24, 2025
Add a new option, `--untrust`, to the `bootstrap` command. Passing a list of account IDs as values to this option removes those account IDs from the trust relationships in the bootstrap roles.

Closes #22703.

----

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

(cherry picked from commit 4713bdd)
moelasmar pushed a commit that referenced this issue Jan 24, 2025
Add a new option, `--untrust`, to the `bootstrap` command. Passing a list of account IDs as values to this option removes those account IDs from the trust relationships in the bootstrap roles.

Closes #22703.

----

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

(cherry picked from commit 4713bdd)
moelasmar pushed a commit that referenced this issue Jan 24, 2025
Add a new option, `--untrust`, to the `bootstrap` command. Passing a list of account IDs as values to this option removes those account IDs from the trust relationships in the bootstrap roles.

Closes #22703.

----

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

(cherry picked from commit 4713bdd)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. documentation This is a problem with documentation. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants