(cdk-cli): unable to get bootstrap working for cross-account deployments #19712
Replies: 4 comments 2 replies
-
This is not a bug. please refer to the docs. |
Beta Was this translation helpful? Give feedback.
-
Hi @mrpackethead thanks for your comment. I came to this issue tracker after consulting with 6 or 7 experienced CDK users on the CDK Slack. We've all looked at the documentation and it doesn't appear to reference this use case in any way. Perhaps we've missed it, so could you please share the documentation referring to bootstrapping two separate accounts then deploying with credentials for one? Appreciate this may not be a "bug", perhaps the label needs to be changed to "documentation issue" or something, but I think it's a legitimate issue to raise either way. |
Beta Was this translation helpful? Give feedback.
-
@rix0rrr you want to chime in here? |
Beta Was this translation helpful? Give feedback.
-
I found a solution that worked for me:
cdk bootstrap --trust account1 --trust-for-lookup account1 --cloudformation-execution-policies 'arn:aws:iam::aws:policy/AdministratorAccess' --profile account2 aws://account2/<your_region> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What is the problem?
I have two stacks - a
LambdaStack
and aBucketStack
.LambdaStack
needs to be deployed toAcc1
BucketStack
needs to be deployed toAcc2
The
BucketStack
requires the Lambda function's role ARN fromLambdaStack
so that the Lambda function can put data intoAcc2
's S3 bucket. For this reason, I need to deploy the stacks from a singlecdk deploy
command rather thancdk deploy LambdaStack
, change creds,cdk deploy BucketStack
etc.When I try to
cdk diff
my code, I receive an error like:Need to perform AWS calls for account 111111Acc1, but the current credentials are for 222222Acc2
.I'm using Okta SSO for AWS where I use the
okta-awscli
python library to assume aaws:arn:blah:Federated_Admin
role. I can run this command for different accounts so my~/.aws/credentials
file is populated as expected, e.g. with adefault
profile (forAcc1
) and anacc2
profile forAcc2
.I have tried to
cdk bootstrap
both accounts (e.g. usingcdk bootstrap --profile acc2 --trust acc1
etc), which appears to complete successfully, but I'm still unable to runcdk diff
.Reproduction Steps
---
~/.aws/credentials
example---
bin/cdk.ts
example--- cdk bootstrapping
--- cdk bootstrapping and diff output
What did you expect to happen?
Expected
cdk diff
to use the bootstrapping process to allow cross-account communication.What actually happened?
Error stating only one account can be called:
Need to perform AWS calls for account 222222Acc2, but the current credentials are for 111111Acc1
CDK CLI Version
2.12.0 (build c9786db)
Framework Version
No response
Node.js Version
v16.13.2
OS
Debian 11, but also tested on MacOS Big Sur
Language
Typescript
Language Version
TypeScript version 4.5.4
Other information
No response
Beta Was this translation helpful? Give feedback.
All reactions