概要
下記の図の基本的なネットワーク構成をCloudfFomationで作成してみました。
流れ
- テンプレート作成
- スタック構築
- 更新
- 削除
テンプレート内容
- 値を替えて使ってみて下さい。
AWSTemplateFormatVersion: '2010-09-09'
Description: test-vpc構成テンプレート
Resources:
TestVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/21
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: default
Tags:
- Key: Name
Value: test-vpc
TestInternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: test-internetgatway
AttachInternetGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref TestVPC
InternetGatewayId: !Ref TestInternetGateway
TestSubnet0:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref TestVPC
CidrBlock: 10.0.0.0/24
AvailabilityZone: ap-northeast-1a
Tags:
- Key: Name
Value: test-subnet-0
TestSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref TestVPC
CidrBlock: 10.0.2.0/24
AvailabilityZone: ap-northeast-1a
Tags:
- Key: Name
Value: test-subnet-2
RouteTableSubnet0:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref TestVPC
Tags:
- Key: Name
Value: rtb-subnet-0
RouteToInternetSubnet0:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref RouteTableSubnet0
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref TestInternetGateway
Subnet0RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref TestSubnet0
RouteTableId: !Ref RouteTableSubnet0
RouteTableSubnet2:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref TestVPC
Tags:
- Key: Name
Value: rtb-subnet-2
Subnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref TestSubnet2
RouteTableId: !Ref RouteTableSubnet2
スタック構築
- 検索欄からCloudFomationを検索し、選択。
スタックの作成を押下する。
作成したテンプレートのymlをアップロードし、スタック名を入力し、「送信」を押下する。




