Skip to content

Instantly share code, notes, and snippets.

@KinzP
Created June 4, 2022 01:25
Show Gist options
  • Save KinzP/66bcff17ad694fa60ac3da3e57aa6b43 to your computer and use it in GitHub Desktop.
Save KinzP/66bcff17ad694fa60ac3da3e57aa6b43 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: '2010-09-09'
Description: NAT Gateway
Parameters:
Owner:
Description: Enter Team or Individual Name Responsible for the Stack.
Type: String
Default: FirstName LastName
VPC:
Description: Select VPC.
Type: AWS::EC2::VPC::Id
PublicSubnet:
Description: Public Subnet to Attach NAT Gateway.
Type: AWS::EC2::Subnet::Id
PrivateRouteTable:
Description: Enter Private Route Table ID.
Type: String
Default: rtb-0000000
PublicNetworkAcl:
Description: Enter Public Network ACL ID.
Type: String
Default: acl-0000000
AllowNatRuleNumber:
Description: Enter Public Network ACL Rule Number to Allow Return NAT Traffic.
Type: Number
Default: '120'
Resources:
NatGateway:
Type: AWS::EC2::NatGateway
DependsOn: NatEIP
Properties:
AllocationId:
Fn::GetAtt:
- NatEIP
- AllocationId
SubnetId:
Ref: PublicSubnet
NatEIP:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
InboundPublicNetworkAclAllowNat:
Type: AWS::EC2::NetworkAclEntry
Properties:
NetworkAclId:
Ref: PublicNetworkAcl
RuleNumber:
Ref: AllowNatRuleNumber
Protocol: '6'
RuleAction: allow
Egress: 'false'
CidrBlock: 0.0.0.0/0
PortRange:
From: '1024'
To: '65535'
Outputs:
Owner:
Description: Team or Individual that Owns this Formation.
Value:
Ref: Owner
VPC:
Description: VPC Used
Value:
Ref: VPC
NatEIP:
Description: NAT Elastic IP Address
Value:
Ref: NatEIP
PublicNetworkACLRuleNumbers:
Description: Public Network ACL Rules Number Created.
Value:
Fn::Join:
- ''
- - Inbound (
- Ref: AllowNatRuleNumber
- ")"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Ownership
Parameters:
- Owner
- Label:
default: Network Configuration
Parameters:
- VPC
- PublicSubnet
- PrivateRouteTable
- PublicNetworkAcl
- AllowNatRuleNumber
ParameterLabels:
Owner:
default: Team or Individual Owner
PublicSubnet:
default: Public Subnet
PrivateRouteTable:
default: Private Route Table
PublicNetworkAcl:
default: Public Network ACL
AllowNatRuleNumber:
default: Public Network ACL Rule Number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment