Skip to content

Instantly share code, notes, and snippets.

@Y4suyuki
Last active September 11, 2024 05:35
Show Gist options
  • Save Y4suyuki/6bfd2e46459ff7182ded7791facfe8fb to your computer and use it in GitHub Desktop.
Save Y4suyuki/6bfd2e46459ff7182ded7791facfe8fb to your computer and use it in GitHub Desktop.
aws cdk glitch about aws credentials

What happened

I setup aws credentials using aws configure sso command and it worked without any problems with aws command. However cdk deploy command could not recognize aws credentials even

  • aws command work without problems
  • cdk synth work without problems

OS and software versions and aws config

OS: archlinux

➜ uname -r
6.10.8-arch1-1

aws cdk was installed via npm

npm i -g aws-cdk

node and npm version as follows

$ node -v
v22.8.0
$ npm -v
10.8.2

cdk version

$ cdk --version
2.156.0 (build 2966832)

.aws/config

[profile my-company-profile]
sso_session_id = my-company
sso_account_id = 1234567890
sso_role_name = AdministratorAccess
region = ap-northeast-1
output = json

[sso-session my-company]
sso_start_url = https://abc.awsapps.com/start#
sso_region = us-east-1
sso_registration_scopes = sso:account:access

How to fix

I changed .aws/config file as below

[profile my-company-profile]
sso_account_id = 1234567890
sso_role_name = AdministratorAccess
region = ap-northeast-1
output = json
sso_start_url = https://abc.awsapps.com/start#
sso_region = us-east-1
  • deleted sso-session section
  • deleted sso_session_id in profile section
  • added sso_start_url and sso_region in profile section

after this it worked both aws command and cdk command including cdk deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment