How to CDK bootstrap or deploy to a not default profile

0

I've created an application containing multiple stacks and tested it out in a test account. Now I want to publish everything to a production account.

Problem is, when I run

cdk bootstrap --profile production

I get this error: ❌ Environment aws://productionaccountnumber/us-east-1 failed bootstrapping: Error: Need to perform AWS calls for account productionaccountnumber, but the current credentials are for testaccountnumber

Same story for deploying my stack.

My credentials file looks like this:

[default]
aws_access_key_id = TESTACCESSKEY
aws_secret_access_key = TESTSECRETKEY
[test]
aws_access_key_id = TESTACCESSKEY
aws_secret_access_key = TESTSECRETKEY
[production]
aws_access_key_id = PRODUCTIONACCESSKEY
aws_secret_access_key = PRODUCTIONSECRETKEY

As a workaround I can copy the production keys to default, and than the stack will be deployed succesfully.

Is this a bug in CDK? Or am I doing something wrong here?

profile picture
asked 4 months ago270 views
1 Answer
1
Accepted Answer

Hello.

A similar conversation is taking place in the GitHub issue below.
https://github.com/aws/aws-cdk/issues/20935

Judging from the comments below, I thought that the [default] profile was getting in the way.
https://github.com/aws/aws-cdk/issues/20935#issuecomment-1698769068

Also, if you look at the answer on stackoverflow below, there is a comment that it worked by deleting the [default] profile, so why not try deleting the [default] profile and running the command?
https://stackoverflow.com/questions/68078955/need-to-perform-aws-calls-for-account-xxx-but-no-credentials-have-been-configur

profile picture
EXPERT
answered 4 months ago
profile picture
EXPERT
reviewed 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions