-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBuild-NetworkAcls.yaml
165 lines (165 loc) · 5.52 KB
/
Build-NetworkAcls.yaml
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
AWSTemplateFormatVersion: 2010-09-09
Description: Build-NetworkAcls Template.
This adds NetworkAcls to an existing Build VPC. This Template is optional, and can be added (or removed) at any time to apply an additional layer of network security. This initially simply replicates the Default NetworkAcl, so we have a Template from which we can iterate to tighten security.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Stack Dependencies
Parameters:
- VPCStackName
ParameterLabels:
VPCStackName:
default: VPC Stack Name
Parameters:
VPCStackName:
Description: Name of the CloudFormation Stack containing the Build VPC
Type: String
MinLength: 6
MaxLength: 64
Default: Build-VPC
AllowedPattern: ^[A-Z][-a-zA-Z0-9]*$
ConstraintDescription: must begin with an upper case letter and contain alphanumeric characters and dashes.
Resources:
PublicNetworkAcl:
Type: AWS::EC2::NetworkAcl
Properties:
VpcId: !ImportValue
Fn::Sub: ${VPCStackName}-VPC
Tags:
- Key: Name
Value: !Sub
- ${VPCName}-PublicNetworkAcl
- VPCName: !ImportValue
Fn::Sub: ${VPCStackName}-VPCName
PublicNetworkAclEntryInbound100:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref PublicNetworkAcl
RuleNumber: 100
Protocol: -1
Egress: false
CidrBlock: 0.0.0.0/0
RuleAction: allow
PublicNetworkAclEntryOutbound100:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref PublicNetworkAcl
RuleNumber: 100
Protocol: -1
Egress: true
CidrBlock: 0.0.0.0/0
RuleAction: allow
PublicSubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-PublicSubnetA
NetworkAclId: !Ref PublicNetworkAcl
PublicSubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-PublicSubnetB
NetworkAclId: !Ref PublicNetworkAcl
Public1SubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-Public1SubnetA
NetworkAclId: !Ref PublicNetworkAcl
Public1SubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-Public1SubnetB
NetworkAclId: !Ref PublicNetworkAcl
WebSubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-WebSubnetA
NetworkAclId: !Ref PublicNetworkAcl
WebSubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-WebSubnetB
NetworkAclId: !Ref PublicNetworkAcl
PrivateNetworkAcl:
Type: AWS::EC2::NetworkAcl
Properties:
VpcId: !ImportValue
Fn::Sub: ${VPCStackName}-VPC
Tags:
- Key: Name
Value: !Sub
- ${VPCName}-PrivateNetworkAcl
- VPCName: !ImportValue
Fn::Sub: ${VPCStackName}-VPCName
PrivateNetworkAclEntryInbound100:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref PrivateNetworkAcl
RuleNumber: 100
Protocol: -1
Egress: false
CidrBlock: 0.0.0.0/0
RuleAction: allow
PrivateNetworkAclEntryOutbound100:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId: !Ref PrivateNetworkAcl
RuleNumber: 100
Protocol: -1
Egress: true
CidrBlock: 0.0.0.0/0
RuleAction: allow
ApplicationSubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-ApplicationSubnetA
NetworkAclId: !Ref PrivateNetworkAcl
ApplicationSubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-ApplicationSubnetB
NetworkAclId: !Ref PrivateNetworkAcl
DatabaseSubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-DatabaseSubnetA
NetworkAclId: !Ref PrivateNetworkAcl
DatabaseSubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-DatabaseSubnetB
NetworkAclId: !Ref PrivateNetworkAcl
BuildSubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-BuildSubnetA
NetworkAclId: !Ref PrivateNetworkAcl
BuildSubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-BuildSubnetB
NetworkAclId: !Ref PrivateNetworkAcl
IdentitySubnetANetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-IdentitySubnetA
NetworkAclId: !Ref PrivateNetworkAcl
IdentitySubnetBNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId: !ImportValue
Fn::Sub: ${VPCStackName}-IdentitySubnetB
NetworkAclId: !Ref PrivateNetworkAcl