公式サイト
node.js & npmのインストール
- ダウンロードURL
https://nodejs.org/en/
node.js と npmのバージョン確認
% node --version
v22.15.0
% npm --version
10.9.2
AWS アカウントの準備
次のURLよりAWSのアカウントを作成(ある場合は、次のステップへ)
Identity and Access Management (IAM)でユーザーとユーザーグループ作成
※ユーザグループに「AdministratorAccess」ポリシーを追加
アクセスキーを作成
ユースケース:コマンドラインインターフェイス (CLI)
アクセスキーと、シークレットキーをメモする
Visual Studio Codeインストール
-
ダウンロードURL
https://code.visualstudio.com/download -
mac版をダウンロードしてインストール
AWS CLI v2をインストール
- ダウンロードURL
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/getting-started-install.html - macOSをクリックして、[GUI installer]タブを選択し、次のmacOS pkgファイルをダウンロードして、インストールする
AWS CLI のインストール確認
- ターミナルを起動して、「aws --version」コマンドを実行し、バージョンを確認
% aws --version
aws-cli/2.27.8 Python/3.13.2 Darwin/24.4.0 exe/x86_64
AWS CLI のプロファイル作成
- ターミナルを起動して、「aws configure --profile $プロファイル名」コマンドを実行し、プロファイルを作成する
% aws configure --profile xxx
AWS Access Key ID [None]: AWSアカウントのアクセスキーを入力
AWS Secret Access Key [None]: AWSアカウントのシークレットキーを入力
Default region name [None]: ap-northeast-1
Default output format [None]: json
AWS CLI のプロファイル確認
- ターミナルを起動して、「aws sts get-caller-identity --profile $プロファイル名」コマンドを実行し、プロファイル及びアカウントIDを確認する
% aws sts get-caller-identity --profile xxx
{
"UserId": "xxxxxxxxxx",
"Account": "xxxxxx",
"Arn": "arn:aws:iam::xxxx:user/xxx"
}
CDKインストール
% sudo chown -R $userName /Users/$userName/.npm/_cacache
% npm install -g aws-cdk
※権限エラーが発生する場合、該当フォルダにユーザーからのアクセス権限を追加
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules
% sudo chown -R $username /usr/local/lib/node_modules
CDKバージョン確認
% cdk --version
2.1013.0 (build 054afef)
% mkdir hello-cdk && cd hello-cdk
% cdk init app --language typescript
AWS アカウントに一回のみ実施
##ブートストラップを実施
$ cdk bootstrap --profile xxx