-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvpc-appliance.yml
297 lines (297 loc) · 8.7 KB
/
vpc-appliance.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
AWSTemplateFormatVersion: 2010-09-09
Description: >
VPC with private subnet service access for the AWS Panorama Appliance.
This template is part of the AWS Panorama guide repository at
https://github.com/awsdocs/aws-panorama-developer-guide
Resources:
vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 172.31.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Ref AWS::StackName
privateSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
CidrBlock: 172.31.3.0/24
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-subnet-a
privateSubnetB:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ""
CidrBlock: 172.31.2.0/24
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-subnet-b
privateRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref vpc
privateSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref privateSubnetA
RouteTableId: !Ref privateRouteTable
privateSubnetBRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref privateSubnetB
RouteTableId: !Ref privateRouteTable
logsEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.logs
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: true
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal: "*"
Action:
- "logs:*"
Resource:
- "*"
monitoringEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.monitoring
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: true
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal: "*"
Action:
- "monitoring:*"
Resource:
- "*"
s3Endpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.s3
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: false
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal: "*"
Action:
- "s3:*"
Resource:
- "*"
s3HostedZone:
Type: AWS::Route53::HostedZone
Properties:
Name: !Sub s3.${AWS::Region}.amazonaws.com
VPCs:
- VPCId: !Ref vpc
VPCRegion: !Ref AWS::Region
s3Records:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !Ref s3HostedZone
Name: !Sub "*.s3.${AWS::Region}.amazonaws.com"
Type: CNAME
TTL: 600
# first DNS entry, split on :, second value of e.g. ["Z1HUB23UULQXV:vpce-01abc23456de78f9g-12abccd3.ec2.us-east-1.vpce.amazonaws.com", "Z...
ResourceRecords:
- !Select [1, !Split [":", !Select [0, !GetAtt s3Endpoint.DnsEntries ] ] ]
s3apHostedZone:
Type: AWS::Route53::HostedZone
Properties:
Name: !Sub s3-accesspoint.${AWS::Region}.amazonaws.com
VPCs:
- VPCId: !Ref vpc
VPCRegion: !Ref AWS::Region
s3apRecords:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !Ref s3apHostedZone
Name: !Sub "*.s3-accesspoint.${AWS::Region}.amazonaws.com"
Type: CNAME
TTL: 600
# first DNS entry, split on :, second value
ResourceRecords:
- !Select [1, !Split [":", !Select [0, !GetAtt s3Endpoint.DnsEntries ] ] ]
iotHostedZone:
Type: AWS::Route53::HostedZone
Properties:
Name: !Sub iot.${AWS::Region}.amazonaws.com
VPCs:
- VPCId: !Ref vpc
VPCRegion: !Ref AWS::Region
iotDataEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.iot.data
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: false
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
iotDataRecords:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !Ref iotHostedZone
Name: !Sub "*.iot.${AWS::Region}.amazonaws.com"
Type: A
AliasTarget:
# first DNS entry, split on :, second value
DNSName: !Select [1, !Split [":", !Select [0, !GetAtt iotDataEndpoint.DnsEntries ] ] ]
# hosted zone of the endpoint, not in this account
HostedZoneId: !Select [0, !Split [":", !Select [0, !GetAtt iotDataEndpoint.DnsEntries ] ] ]
EvaluateTargetHealth: true
iotCredentialsEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.iot.credentials
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: false
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
iotCredentialsRecords:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !Ref iotHostedZone
Name: !Sub "*.credentials.iot.${AWS::Region}.amazonaws.com"
Type: A
AliasTarget:
# first DNS entry, split on :, second value
DNSName: !Select [1, !Split [":", !Select [0, !GetAtt iotCredentialsEndpoint.DnsEntries ] ] ]
# hosted zone of the endpoint, not in this account
HostedZoneId: !Select [0, !Split [":", !Select [0, !GetAtt iotCredentialsEndpoint.DnsEntries ] ] ]
EvaluateTargetHealth: true
ecrServiceEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.ecr.api
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: true
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
ecrDockerEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
ServiceName: !Sub com.amazonaws.${AWS::Region}.ecr.dkr
VpcId: !Ref vpc
VpcEndpointType: Interface
SecurityGroupIds:
- !GetAtt vpc.DefaultSecurityGroup
PrivateDnsEnabled: true
SubnetIds:
- !Ref privateSubnetA
- !Ref privateSubnetB
publicSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref vpc
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
CidrBlock: 172.31.0.0/24
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-public-subnet
internetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-gateway
gatewayToInternet:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref vpc
InternetGatewayId: !Ref internetGateway
publicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref vpc
publicRoute:
Type: AWS::EC2::Route
DependsOn: gatewayToInternet
Properties:
RouteTableId: !Ref publicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref internetGateway
publicSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref publicSubnet1
RouteTableId: !Ref publicRouteTable
Outputs:
vpcID:
Description: VPC ID
Value: !Ref vpc
Export:
Name: !Sub ${AWS::StackName}-vpc
vpcSecurityGroup:
Description: Default security group for VPC
Value: !GetAtt vpc.DefaultSecurityGroup
Export:
Name: !Sub ${AWS::StackName}-vpc-sg
privateSubnetAID:
Description: Private Subnet A ID
Value: !Ref privateSubnetA
Export:
Name: !Sub ${AWS::StackName}-subnet-a
privateSubnetBID:
Description: Private Subnet B ID
Value: !Ref privateSubnetB
Export:
Name: !Sub ${AWS::StackName}-subnet-b
publicSubnet1ID:
Description: Public Subnet A ID
Value: !Ref publicSubnet1
Export:
Name: !Sub ${AWS::StackName}-subnet-public