-
Notifications
You must be signed in to change notification settings - Fork 7
/
(b+c)cloudformation.yml
169 lines (167 loc) · 4.42 KB
/
(b+c)cloudformation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Template of ECS_CICD_Handson_v3.pptx
Mappings:
StackConfig:
VPC:
CIDR: 10.1.0.0/16
PublicSubnet1:
CIDR: 10.1.0.0/24
PrivateSubnet1:
CIDR: 10.1.1.0/24
PublicSubnet2:
CIDR: 10.1.2.0/24
PrivateSubnet2:
CIDR: 10.1.3.0/24
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !FindInMap [ StackConfig, VPC, CIDR ]
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: handson-vpc
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: handson-vpc-igw
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
PublicRouteTable:
Type: AWS::EC2::RouteTable
DependsOn: AttachGateway
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: handson-vpc-public-route-table
PublicRoute:
Type: AWS::EC2::Route
DependsOn: AttachGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
PublicSubnet1:
Type: AWS::EC2::Subnet
DependsOn: AttachGateway
Properties:
VpcId: !Ref VPC
AvailabilityZone: ap-northeast-1b
CidrBlock: !FindInMap [ StackConfig, PublicSubnet1, CIDR ]
Tags:
- Key: Name
Value: Public subnet
PublicSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet1
RouteTableId: !Ref PublicRouteTable
PublicSubnet2:
Type: AWS::EC2::Subnet
DependsOn: AttachGateway
Properties:
VpcId: !Ref VPC
AvailabilityZone: ap-northeast-1c
CidrBlock: !FindInMap [ StackConfig, PublicSubnet2, CIDR ]
Tags:
- Key: Name
Value: Public subnet 2
PublicSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnet2
RouteTableId: !Ref PublicRouteTable
EipForNatGW1:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGW1:
Type: AWS::EC2::NatGateway
DependsOn : EipForNatGW1
Properties:
AllocationId: !GetAtt EipForNatGW1.AllocationId
SubnetId: !Ref PublicSubnet1
Tags:
- Key: Name
Value: handson-vpc-natgw-1
EipForNatGW2:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGW2:
Type: AWS::EC2::NatGateway
DependsOn : EipForNatGW2
Properties:
AllocationId: !GetAtt EipForNatGW2.AllocationId
SubnetId: !Ref PublicSubnet2
Tags:
- Key: Name
Value: handson-vpc-natgw-1
PrivateRouteTable1:
Type: AWS::EC2::RouteTable
DependsOn : NatGW1
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: handson-vpc-private-route-table-1
PrivateRoute1:
Type: AWS::EC2::Route
DependsOn : NatGW1
Properties:
RouteTableId: !Ref PrivateRouteTable1
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGW1
PrivateRouteTable2:
Type: AWS::EC2::RouteTable
DependsOn : NatGW2
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: handson-vpc-private-route-table-2
PrivateRoute2:
Type: AWS::EC2::Route
DependsOn : NatGW2
Properties:
RouteTableId: !Ref PrivateRouteTable2
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NatGW2
PrivateSubnet1:
Type: AWS::EC2::Subnet
DependsOn : NatGW1
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs "" ]
CidrBlock: !FindInMap [ StackConfig , PrivateSubnet1 , CIDR ]
Tags:
- Key: Name
Value: Private subnet
PrivateSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet1
RouteTableId: !Ref PrivateRouteTable1
PrivateSubnet2:
Type: AWS::EC2::Subnet
DependsOn : NatGW2
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 1, !GetAZs "" ]
CidrBlock: !FindInMap [ StackConfig , PrivateSubnet2 , CIDR ]
Tags:
- Key: Name
Value: Private subnet 2
PrivateSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PrivateSubnet2
RouteTableId: !Ref PrivateRouteTable2