The error is produced by CDK because it can't resolve valid AWS CLI credentials which allows it to resolve the account by making a call similar to
aws sts get-caller-identity --profile profile_name
There are multiple ways to configure the AWS CLI with valid credentials so that CDK can interact with the CLI configuration to obtain credentials
- In ~/.aws/credentials, which is easiest and least preferred/secure way due to using longterm creds, you can place longterm credentials assigned to an IAM user like this
[default]
aws_access_key_id=AKIAI44QH8DHBEXAMPLE
aws_secret_access_key=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
- Using credential process https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sourcing-external.html
In ~/.aws/config
[profile developer]
credential_process = /opt/bin/awscreds-custom --username helen
Using a more secure tool like https://github.com/99designs/aws-vault
Using AWS CLI integration with AWS SSO. This setup allows for SSO across multiple accounts and supports multiple MFA strategies including biometric. The problem with this is that the current version of the CDK has not been updated to use the latest version of the Node AWS SDK so it does not know how to retrieve credentials. Hopefully a future release of CDK will resolve this but its been almost 2 years
In ~/.aws/config
[profile sso_profile]
sso_start_url = https://sso_url.awsapps.com/start
sso_region = us-east-2
sso_account_id =
sso_role_name = AWSAdministratorAccess
region = us-east-2
output=json
Fortunately there is a decent workaround which works seamlessly once configured. This involves utilizing a python lib that can expose an SSO profile as a credentials process which is supported by current CDK.
Install https://pypi.org/project/aws2-wrap/
pip3 install aws2-wrap==1.2.7
Then in ~/.aws/config add a wrapper profile that uses aws2-wrap to exposes as a credentials process
[profile wrapped_sso_profile]
region = us-east-2
credential_process = aws2-wrap --process --profile sso_profile