0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MacでAWSのCDK環境を構築

Last updated at Posted at 2025-05-08

公式サイト

node.js & npmのインストール

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インストール

AWS CLI v2をインストール

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
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?