question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cdk <command> --profile <named profile> tries default regardless

See original GitHub issue

cdk commands does not pick up the named profile from .aws/credential and ./aws/config. the profile is configured thru aws configure and in the format as specified in the aws doc. (two files, [<profile name>] in credential file and [profile <profile name>] in config file.

Reproduction Steps

create the profile specify account number and region in the stack env. run cdk synth or cdk deploy with --profile <profile name>

Error Log

[Error at /test-stack] Need to perform AWS calls for account ************, but no credentials found. Tried: default credentials.
Found errors

Environment

  • **CLI Version : 1.16.3 **
  • **Framework Version: 1.16.3 **
  • OS : mac os
  • **Language : python **

Other

Also tried to remove the [default] blocks in the .aws/ files, still same error.


This is 🐛 Bug Report

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:12
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
vzakharchenkocommented, Dec 4, 2019

This solution is works for me:

~/.aws/config

[profile testProfile] region = us-east-1

~/.aws/credentials

[testProfile] role_arn = arn:aws:iam::... aws_access_key_id = ***** aws_secret_access_key = ********* source_profile=testProfile

command to deploy: cdk deploy --profile=testProfile

Environment

  • CDK_CLI_ASM_VERSION: ‘1.16.0’,
  • CDK_CLI_VERSION: ‘1.18.0’
  • OS : mac os
  • Language : java
1reaction
rafzeicommented, Jun 14, 2022

Try with the --verbose flag to get the error. In my case, it was Unable to determine the default AWS account: InvalidClientTokenId: The security token included in the request is invalid. And it turned out that aws_secret_access_key contains the plus (+) sign that causes the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

aws cdk to use non-default profile - Stack Overflow
By default, CDK commands will use the default AWS CLI profile. However, you can specify a named profile for a project by adding...
Read more >
How to use a different Profile in AWS CDK | bobbyhadz
We can set the profile in a CDK command by passing the `--profile` flag. ... the profile we've specified, or the default one...
Read more >
Chapter 2. Using CDK Red Hat Container Development Kit 3.12
By default, the minishift command places all runtime state into ~/.minishift. ... Profile names can only consist of alphanumeric characters.
Read more >
How to migrate from CloudFormation to AWS CDK - part 1
You can essentially use AWS CDK command-line tool to make a better ... specify the name of the profile, if the profile name...
Read more >
AWS CDK Toolkit (cdk command) - AWS Documentation
The AWS CDK Toolkit, the CLI command cdk , is the primary tool for interacting with your AWS CDK app. ... Do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found