Skip to content

Commit 547966b

Browse files
committed
Switch to NAT Gateway
1 parent b124fe4 commit 547966b

File tree

4 files changed

+54
-18
lines changed

4 files changed

+54
-18
lines changed

spire/templates/apps/dovetail-counts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Resources:
128128
prx:dev:application: Counts
129129
Timeout: 30
130130
VpcConfig:
131-
Ipv6AllowedForDualStack: true
131+
# Ipv6AllowedForDualStack: true
132132
SecurityGroupIds:
133133
- !GetAtt CountsFunctionSecurityGroup.GroupId
134134
- !Ref KinesisStreamsEndpointAccessSecurityGroupId

spire/templates/shared-vpc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ Resources:
166166
VpcIpv6CidrBlocks: !Join [",", !GetAtt Vpc.Ipv6CidrBlocks]
167167
AvailabilityZoneSelectorServiceToken: !Ref AvailabilityZoneSelectorServiceToken
168168
NetworkAclName: !GetAtt PrivateNetworkAclStack.Outputs.NetworkAclName
169+
Subnet1NatGatewayId: !GetAtt PublicSubnetsStack.Outputs.Subnet1NatGatewayId
169170
Tags:
170171
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
171172
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }

spire/templates/shared-vpc/private-subnets.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Parameters:
1515
VpcIpv6CidrBlocks: { Type: CommaDelimitedList }
1616
AvailabilityZoneSelectorServiceToken: { Type: String }
1717
NetworkAclName: { Type: String }
18+
Subnet1NatGatewayId: { Type: String }
1819

1920
Conditions:
2021
EnableNestedChangeSetScrubbingResources: !Equals [!Ref NestedChangeSetScrubbingResourcesState, Enabled]
@@ -28,19 +29,19 @@ Resources:
2829
ServiceToken: !Ref AvailabilityZoneSelectorServiceToken
2930

3031
# Egress-only internet gateway
31-
EgressOnlyInternetGateway:
32-
Type: AWS::EC2::EgressOnlyInternetGateway
33-
Properties:
34-
Tags:
35-
- { Key: Name, Value: !Sub "${RootStackName}_shared_private" }
36-
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
37-
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
38-
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
39-
- { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
40-
- { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
41-
- { Key: prx:ops:environment, Value: !Ref EnvironmentType }
42-
- { Key: prx:dev:application, Value: Common }
43-
VpcId: !Ref VpcId
32+
# EgressOnlyInternetGateway:
33+
# Type: AWS::EC2::EgressOnlyInternetGateway
34+
# Properties:
35+
# Tags:
36+
# - { Key: Name, Value: !Sub "${RootStackName}_shared_private" }
37+
# - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
38+
# - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
39+
# - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
40+
# - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
41+
# - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
42+
# - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
43+
# - { Key: prx:dev:application, Value: Common }
44+
# VpcId: !Ref VpcId
4445

4546
# Routing for private subnets. A subnet being associated with this route
4647
# table is what makes it a private subnet, since there is no internet gateway
@@ -59,14 +60,12 @@ Resources:
5960
- { Key: prx:ops:environment, Value: !Ref EnvironmentType }
6061
- { Key: prx:dev:application, Value: Common }
6162

62-
# Add a Egress-only Internet Gateway route, to allow resources in private subnets
63-
# to access the internet without being exposed to the internet directly
64-
PrivateRouteTableEgressOnlyRoute:
63+
PrivateRouteTableNatRoute:
6564
Type: AWS::EC2::Route
6665
Properties:
6766
RouteTableId: !Ref PrivateRouteTable
6867
DestinationIpv6CidrBlock: ::/0
69-
EgressOnlyInternetGatewayId: !Ref EgressOnlyInternetGateway
68+
NatGatewayId: !Ref Subnet1NatGatewayId
7069

7170
# Private subnets
7271
PrivateSubnet1:

spire/templates/shared-vpc/public-subnets.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,39 @@ Resources:
4646
InternetGatewayId: !Ref InternetGateway
4747
VpcId: !Ref VpcId
4848

49+
# NAT Gateway in the public subnet so it can access the internet, which will
50+
# be used by resources in the private subnet so they can reach the internet
51+
Subnet1NatGatewayElasticIp:
52+
Type: AWS::EC2::EIP
53+
Properties:
54+
Domain: vpc
55+
Tags:
56+
- { Key: Name, Value: !Sub "${RootStackName}_nat-gateway" }
57+
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
58+
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
59+
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
60+
- { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
61+
- { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
62+
- { Key: prx:ops:environment, Value: !Ref EnvironmentType }
63+
- { Key: prx:dev:application, Value: Common }
64+
Subnet1NatGateway:
65+
Type: AWS::EC2::NatGateway
66+
Properties:
67+
AllocationId: !GetAtt Subnet1NatGatewayElasticIp.AllocationId
68+
ConnectivityType: public
69+
MaxDrainDurationSeconds: 350
70+
SubnetId: !Ref PublicSubnet1
71+
Tags:
72+
- { Key: Name, Value: !Sub "${RootStackName}_nat-gateway" }
73+
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
74+
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
75+
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
76+
- { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
77+
- { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
78+
- { Key: prx:ops:environment, Value: !Ref EnvironmentType }
79+
- { Key: prx:dev:application, Value: Common }
80+
VpcId: !Ref VpcId
81+
4982
# Routing for public subnets. A subnet being associated with this route table
5083
# is what makes it a public subnet, since there's an internet gateway
5184
# associated with the route table.
@@ -186,6 +219,9 @@ Outputs:
186219
Description: The name of the internet gateway
187220
Value: !Ref InternetGateway
188221

222+
Subnet1NatGatewayId:
223+
Value: !Ref Subnet1NatGateway
224+
189225
Subnet1Id:
190226
Description: ID of public subnet 1
191227
Value: !Ref PublicSubnet1

0 commit comments

Comments
 (0)