Closed13
【公式チュートリアル】TypeScript の基礎から始める AWS CDK 開発入門

下記ワークショップを使って進める
ワークショップ
ドキュメント(VPCはEC2のページにある)
overview

下記を実行する
cdk init sample-app --language=typescript
Applying project template sample-app for typescript
# Welcome to your CDK TypeScript project
You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`CdkSampleStack`)
which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic.
The `cdk.json` file tells the CDK Toolkit how to execute your app.
## Useful commands
* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests
* `cdk deploy` deploy this stack to your default AWS account/region
* `cdk diff` compare deployed stack with current state
* `cdk synth` emits the synthesized CloudFormation template
Executing npm install...
npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
✅ All done!

実行後
cdk-workshop/
├── bin/
│ └── cdk-workshop.ts
├── lib/
│ └── cdk-workshop-stack.ts
├── node_modules/
├── test/
│ └── cdk-workshop.test.ts
├── .git/
├── cdk.json
├── jest.config.js
├── package.json
├── README.md
├── tsconfig.json
├── .gitignore
└── .npmignore

アプリケーションで定義されたスタックごとにCloudFormationテンプレートを合成
cdk synth
CloudFormationテンプレートが出力される

初めてデプロイするときはブートストラップスタックをデプロイする必要あり
cdk bootstrap

デプロイ
cdk deploy
CDKアプリケーションはCloudformationを通じてデプロイされる

現在デプロイされているものの違いを確認する
dck deployを実行したときに何が起こるかを確認できる
cdk diff

cdk_sample/bin/cdk_sample.ts
がエントリポイント
lib/cdk_sample-stack.ts
メインスタックを定義する

デプロイできた!

リソースの削除
cdk destroy
Are you sure you want to delete: CdkSampleStack (y/n)? y
CdkSampleStack: destroying... [1/1]

アクセスできなくなったことを確認

デプロイ終了したためクローズ
このスクラップは2025/02/10にクローズされました