skip to Main Content

I have seen related questions for this issue.

But my problem in particular is I am assuming a role to retrieve temporary credenitals. It works just fine; however, when running CDK Bootstrap, I receive: Need to perform AWS calls for account <account_id>, but no credentials have been configured.

I have tried using CDK Deploy as well and I receive: Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environment

How can I specify AWS Account enviornment in CDK when using temp credentials or assuming role?

2

Answers


  1. you need to define the account you are attempting to bootstrap too.

    for bootstrap you can use it as part of the command – cdk bootstrap aws://ACCOUNT-NUMBER-1/REGION-1 aws://ACCOUNT-NUMBER-2/REGION-2 ... do note that a given account/region only ever has to be bootstrapped ONCE in its lifetime, no matter how many cdk stacks are going to be deployed there.

    AND your credentials need to be part of the default profile. If you are assuming credentials through some sort of enterprise script, please check with them that they store it as part of the default profile. If not, run at least aws config in your bash terminal and get your temp assumed credentials in there

    For cdk deploy you need to make sure in your app.py that you have the env defined

    env_EU = cdk.Environment(account="8373873873", region="eu-west-1")
    env_USA = cdk.Environment(account="2383838383", region="us-west-2")
    
    MyFirstStack(app, "first-stack-us", env=env_USA)
    MyFirstStack(app, "first-stack-eu", env=env_EU)
    

    i would however recommend against hardcoding your account numbers ๐Ÿ˜‰

    Login or Signup to reply.
  2. the name of credential and config file should be the same
    like:

    -credentials
    [cdk]
    aws_access_key_id = xxxxxxxxxxx
    aws_secret_access_key = xxxxxxxxxxx
    -config
    [cdk]
    region = "us-east-1"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search