<1> 요청 사항 - Pub3 , Pri3 , DB 2 Subnet
<2> Cloudformation 코드에 들어가야 하는것
<3> Cloudformation 내용
<4> 다른 Cloudformation 파일 보기
<1> 요청 사항 - Pub3 , Pri3 , DB 2 Subnet
VPC 1개
Public Subnet 3개
Private Sunet 3개
DB Subnet 2개
<2> Cloudformation 코드에 들어가야 하는것
pub관련 8개
PublicSubnet1
PublicSubnet2
PublicSubnet3
PublicRouteTable 테이블
PublicRoute 0.0.0.0
PublicSubnetRouteTableAssociation1
PublicSubnetRouteTableAssociation2:
PublicSubnetRouteTableAssociation3
private 관련 7개
PrivateSubnet1
PrivateSubnet2
PrivateSubnet3
PrivateRouteTable: 테이블
PrivateSubnetRouteTableAssociation1:
PrivateSubnetRouteTableAssociation2
PrivateSubnetRouteTableAssociation3
DB관련 5개
dbsubnert1:
dbsubnert3:
dbroutettable: 테이블
dbsubnertRouteTableAssociation1:
dbsubnertRouteTableAssociation2
공통 3개
VPC
IGW
IGW Attatch
<3> Cloudformation 내용
설정 파일
AWSTemplateFormatVersion: 2010-09-09
Description: Deploy a VPC
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.10.10.0/23
EnableDnsHostnames: true
Tags:
- Key: Name
Value: s0-dev-vpc
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: igw
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
PublicSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.10.0/26
AvailabilityZone: !Select
- '0'
- !GetAZs ''
Tags:
- Key: Name
Value: Pub-Subnet-a
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.11.0/26
AvailabilityZone: !Select
- '0'
- !GetAZs ''
Tags:
- Key: Name
Value: Pri-Subnet-a
dbsubnert1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.10.192/26
AvailabilityZone: !Select
- '0'
- !GetAZs ''
Tags:
- Key: Name
Value: db-subnet-a
PublicSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.10.64/26
AvailabilityZone: !Select
- '1'
- !GetAZs ''
Tags:
- Key: Name
Value: Pub-Subnet-b
PrivateSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.11.64/26
AvailabilityZone: !Select
- '1'
- !GetAZs ''
Tags:
- Key: Name
Value: Pri-Subnet-b
PublicSubnet3:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.10.128/26
AvailabilityZone: !Select
- '2'
- !GetAZs ''
Tags:
- Key: Name
Value: Pub-Subnet-c
PrivateSubnet3:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.11.128/26
AvailabilityZone: !Select
- '2'
- !GetAZs ''
Tags:
- Key: Name
Value: Pri-Subnet-c
dbsubnert3:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.10.11.192/26
AvailabilityZone: !Select
- '2'
- !GetAZs ''
Tags:
- Key: Name
Value: db-subnet-c
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: Pub-rt
PublicRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnetRouteTableAssociation1:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet1
RouteTableId: !Ref PublicRouteTable
PublicSubnetRouteTableAssociation2:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2
RouteTableId: !Ref PublicRouteTable
PublicSubnetRouteTableAssociation3:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet3
RouteTableId: !Ref PublicRouteTable
PrivateRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: Pri-rt
PrivateSubnetRouteTableAssociation1:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet1
RouteTableId: !Ref PrivateRouteTable
PrivateSubnetRouteTableAssociation2:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet2
RouteTableId: !Ref PrivateRouteTable
PrivateSubnetRouteTableAssociation3:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet3
RouteTableId: !Ref PrivateRouteTable
PrivateRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: Pri-rt
dbroutettable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: db-rt
dbsubnertRouteTableAssociation1:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref dbsubnert1
RouteTableId: !Ref dbroutettable
dbsubnertRouteTableAssociation3:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref dbsubnert3
RouteTableId: !Ref dbroutettable
Outputs:
VPC:
Description: VPC
Value: !Ref VPC
AZ1:
Description: Availability Zone 1
Value: !GetAtt
- PublicSubnet1
- AvailabilityZone
AZ2:
Description: Availability Zone 2
Value: !GetAtt
- PublicSubnet2
- AvailabilityZone
AZ3:
Description: Availability Zone 2
Value: !GetAtt
- PublicSubnet3
- AvailabilityZone
<4> 다른 Cloudformation 파일 보기
https://brunch.co.kr/@topasvga/1781