Skip to content

Instantly share code, notes, and snippets.

@matbos

matbos/second.yaml

Created May 7, 2020
Embed
What would you like to do?
Cloudformation template with VPC and NAT Gateway for the second example from http://rozchmurzeni.pl/vpc---prywatne-podsieci
AWSTemplateFormatVersion: 2010-09-09
Description: >-
VPC with NAT Gateway for the second example from http://rozchmurzeni.pl/vpc---prywatne-podsieci
Resources:
Vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
InternetGateway:
Type: AWS::EC2::InternetGateway
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref Vpc
# Publiczny subnet
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref Vpc
InternetRoute:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
RouteTableId: !Ref PublicRouteTable
GatewayId: !Ref InternetGateway
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: eu-west-1a
CidrBlock: 10.0.1.0/24
MapPublicIpOnLaunch: true
VpcId: !Ref Vpc
PublicSubnetTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet
# NAT gateway
ElasticIpForNat:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
NatGateway:
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt ElasticIpForNat.AllocationId
SubnetId: !Ref PublicSubnet
# Subnet aplikacji
ApplicationSubnetRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref Vpc
InternetRoute:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
RouteTableId: !Ref ApplicationSubnetRouteTable
NatGatewayId: !Ref NatGateway
ApplicationSubnet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: eu-west-1a
CidrBlock: 10.0.3.0/24
VpcId: !Ref Vpc
ApplicationSubnetTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref ApplicationSubnetRouteTable
SubnetId: !Ref ApplicationSubnet
# Subnet bazy danych
DatabaseRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref Vpc
DatabaseSubnet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: eu-west-1a
CidrBlock: 10.0.4.0/24
VpcId: !Ref Vpc
DatabaseSubnetTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref DatabaseRouteTable
SubnetId: !Ref DatabaseSubnet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.