# clone the project, and initial the project directory first
$ git clone https://github.com/BabooPan/cdk-ecs-2048-on-fargate.git
$ cd cdk-ecs-2048-on-fargate
# init the packages needed for this demo
$ yarn install
yarn install v1.22.17
warning ../../../package.json: No license field
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
✨ Done in 4.45s.
# confirm the dependencies again by projen
$ npx projen
👾 default | node .projenrc.js
透過 cdk deploy
做部署,若在部署的 AWS Account 或是 Region 中沒有配置過 CDK Toolkit,會報錯提示需要執行 cdk bootstrap aws://012345678901/us-west-2
CDK Toolkit 為幫助 CDK 以 CloudFormation 部署相關資源的工具,會先將 CDK 所需要的項目與資源放置在自動生成的 S3 Bucket ,或是生成 IAM Role 來確保 CDK 部署 Applications 所需要的權限;這個事前部署的階段稱為 CDK Bootstrapping
# the cdk v2 need to boostrap first
$ cdk bootstrap aws://012345678901/us-west-2 # boostrap CDK toolkit
...
...
⏳ Bootstrapping environment aws://012345678901/us-west-2...
CDKToolkit: creating CloudFormation changeset...
[██████████████████████████████████████████████████████████] (3/3)
✅ Environment aws://012345678901/us-west-2 bootstrapped.
可以透過 CloudFormation Console 確認 CDK Toolkit 的部署狀況
再用 cdk deploy
做部署 CloudFormation Stack
$ cdk deploy
...
Do you wish to deploy these changes (y/n)? y
...
cdk-ecs-2048-on-fargate: deploying...
...
cdk-ecs-2048-on-fargate: creating CloudFormation changeset...
[██████████████████████████████████████████████████████████] (9/9)
✅ cdk-ecs-2048-on-fargate
Outputs:
...
...
如果不用了,記得透過 cdk destory
刪除 CloudFormation Stack
$ cdk destory
...
Are you sure you want to delete: cdk-ecs-2048-on-fargate (y/n)? y
cdk-ecs-2048-on-fargate: destroying...
...
7:19:27 PM | DELETE_IN_PROGRESS | AWS::CloudFormation::Stack | cdk-ecs-2048-on-fargate
✅ cdk-ecs-2048-on-fargate: destroyed