2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environmentの対処法

Posted at

エラー内容

cdk init コマンド後の cdk bootstrap コマンドが上手く実行できない

  • コマンド
cdk bootstrap
  • 実行例
>cdk bootstrap

Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environment

原因

  1. 環境変数がおかしい
  2. aws configure が設定されていない

対処法

1. 環境変数がおかしい場合の対処法

問題がないかチェック

  • コマンド
cdk doctor
  • 実行例
$ cdk doctor
ℹ️ CDK Version: 2.53.0 (build 7690f43)
ℹ️ AWS environment variables:
  - AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  - AWS_STS_REGIONAL_ENDPOINTS = regional
ℹ️ No CDK environment variables

環境変数で変な設定している箇所を探す

  • コマンド
export -p
  • 実行例
$ export -p
...省略
declare -x AWS_ACCESS_KEY_ID="hogehoge"
declare -x AWS_SECRET_ACCESS_KEY="fugafuga"
declare -x AWS_REGION="us-east-1"
...省略

環境変数を消す

  • コマンド
unset 【環境変数】
  • 実行例
$ unset AWS_ACCESS_KEY_ID
$ unset AWS_SECRET_ACCESS_KEY
$ unset AWS_REGION

2. aws configure が設定されていない場合の対処法

aws configure コマンドを実行して設定する

  • コマンド
aws configure
  • 実行例
>aws configure
AWS Access Key ID [None]: hogehoge
AWS Secret Access Key [None]: fugafuga
Default region name [None]: ap-northeast-1
Default output format [None]: json

成功例

以下のようになれば成功

  • コマンド
cdk bootstrap
  • 実行例
>cdk bootstrap
 ⏳  Bootstrapping environment aws://【AWSアカウントID】/【リージョン】...
Trusted accounts for deployment: (none)
Trusted accounts for lookup: (none)
...省略
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?