前回は
cdk synth
コマンドでCDKコードをCloudFormationテンプレートに変換するところまで実施しました
後続の、
cdk bootstrap
コマンドの前にAWSアカウントとCLIが連携しているのかを確認しました
確認コマンド(“いま誰としてAWSにログインしているか”を確定させる確認コマンド)
aws sts get-caller-identity
以下のエラーが表示
zsh: command not found: aws
原因:AWS CLI未インストール
CLIをインストール
brew install awscli
完了したら確認
aws --version
以下と表示される
aws-cli/2.33.31 Python/3.13.12 Darwin/23.6.0 source/arm64
これでCLIのインストールは完了
次にAWSアカウントに接続されているのかの確認
aws sts get-caller-identity
Unable to locate credentials. You can configure credentials by running "aws login".
と表示される
原因は、AWS認証情報が設定されていない
aws login
コマンドを打って、ブラウザでAWSアカウントでログイン。
その際に、
You are able to change the region in the CLI at any time with the command "aws configure set region NEW_REGION". AWS Region [us-east-1]:
と聞かれる
リージョンが未設定なので
ap-northeast-1
と入力
実行後に再度
aws sts get-caller-identity
コマンドを入力すると、アカウントIDが表示される。