cdk deployを実行して「Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment」のエラーが発生した場合の解決策の一つとして記載します。
前提条件
- Ubuntu 18.04.4 LTS(WSLの利用)
cdk deploy --profile xxx を実行すると Unable to resolve~エラー
$ cdk deploy --profile xxx
Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment
- ~/.aws/configを確認する
~/.aws/config
$ cat ~/.aws/config
[profile xxx]
region = ap-northeast-1
[default]
region = ap-northeast-1
[xxx]
region = ap-northeast-1
- [profile xxx]を削除する
~/.aws/config
$ cat ~/.aws/config
[default]
region = ap-northeast-1
[xxx]
region = ap-northeast-1
- cdk deployの再実行
$ cdk deploy --profile xxx
CdkXXXXXXXStack: deploying...
CdkXXXXXXXStack: creating CloudFormation changeset...
[██████████████████████████████████████████████████████████] (3/3)
✅ CdkDynamodbStack
Stack ARN:
arn:aws:cloudformation:ap-northeast-1:XXXXXXXXXXXX:stack/CdkXXXXXXXStack/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
解決