---
AWS User Group Taiwan Meetup 2021-12 線上 / 下小聚
書籍特色
目前支援語言 TypeScript, JavaScript, Python, Java, C#/.Net 還有正在 preview 的 Go
如下 20 行的 CDK 可以變出高達 500 行的 CloudFormation 腳本
export class MyEcsConstructStack extends core.Stack { constructor(scope: core.App, id: string, props?: core.StackProps) { super(scope, id, props); const vpc = new ec2.Vpc(this, "MyVpc", { maxAzs: 3 // 使用 3 個 AZ }); const cluster = new ecs.Cluster(this, "MyCluster", { vpc: vpc }); // 建立 ALB 串接 Fargate 的 ECS Service new ecs_patterns.ApplicationLoadBalancedFargateService(this, "MyFargateService", { cluster, taskImageOptions: { image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample") }, publicLoadBalancer: true // 預設為 false 僅內部使用 ALB }); } }
此程式定義了 50 種資源
此程式定義了 50 種資源
超好用的自動補完提示
python3 -m pip install --no-input --upgrade awscli
npm install -g aws-cdk
$ aws configure AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY Default region name [None]: us-west-2 Default output format [None]:
$ aws sts get-caller-identity
{
"UserId": "AKIAIOSFODNN7EXAMPLE",
"Account": "888888888888",
"Arn": "arn:aws:iam::888888888888:user/clarence"
}
cdk list
aka cdk ls
cdk synthesize
aka cdk synth
cdk synth --json
cdk bootstrap
cdk deploy
cdk watch
cdk destroy
cdk diff
cdk docs
cdk init
cdk init --list
cdk init -l typescript
cdk init lib
--require-approval=never
AWS_DEFAULT_REGION=us-west-2 cdk deploy
mkdir hello-cdk && cd hello-cdk cdk init --language=typescript
mkdir hello-cdk && cd hello-cdk npx projen new awscdk-app-ts
mkdir hello-cdk && cd hello-cdk npx projen new awscdk-app-ts --cdk-version 2.1.0
import * as s3 from '@aws-cdk/aws-s3'; import * as s3deploy from '@aws-cdk/aws-s3-deployment';
aws_s3 as s3 aws_s3_deployment as s3deploy