Slide 27
Slide 27 text
©Fusic Co., Ltd. 26
CDKのコンストラクト概念
CDKを使う上で必要な概念
L1 ほぼCloudFormationレベルで詳細に実装できる
import { Stack, Construct, StackProps } from '@aws-cdk/core';
import {
CfnVPC,
CfnSubnet,
CfnInternetGateway,
CfnRouteTable,
CfnRoute,
CfnSubnetRouteTableAssociation, CfnVPCGatewayAttachment
} from "@aws-cdk/aws-ec2";
export class LabStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const vpc = new CfnVPC(this, "lab-vpc", {
cidrBlock: "10.0.0.0/16",
enableDnsHostnames: true,
enableDnsSupport: true,
tags: [ { key: "Name", value: "lab-vpc" } ]
});
const publicSubnet = new CfnSubnet(this, "lab-subnet", {
vpcId: vpc.ref,
cidrBlock: "10.0.0.0/24",
availabilityZone: this.availabilityZones[0],
tags: [ { key: "Name", value: "lab-subnet" } ]
});
const igw = new CfnInternetGateway(this, "lab-igw", {
tags: [ { key: "Name", value: "lab-igw" } ]
});
const igwAttach = new CfnVPCGatewayAttachment(this, "lab-igw-attach", {
vpcId: vpc.ref,
VPC/Public Subnet/IGW/RouteTableを作る例
https://dev.classmethod.jp/articles/aws-cdk-layer/
今回のハンズオンのアーキテクチャでは使っていません
用途としては、特異なリソースを作成するときや、
上位レイヤーでのサポートがないWAFのルール
などが必要なときなどがあります