113 lines
3.5 KiB
YAML
113 lines
3.5 KiB
YAML
AWSTemplateFormatVersion: 2010-09-09
|
|
Description: VPC and Subnet definitions for Strapi + ELB project.
|
|
Resources:
|
|
PublicVPC:
|
|
Type: AWS::EC2::VPC
|
|
Properties:
|
|
CidrBlock: "172.31.0.0/16"
|
|
EnableDnsHostnames: true
|
|
EnableDnsSupport: true
|
|
PublicSecurityGroup:
|
|
Type: AWS::EC2::SecurityGroup
|
|
Properties:
|
|
GroupName: !Sub "${AWS::StackName}-PublicSecurityGroup"
|
|
GroupDescription: Security group for the EC2 instances. This group does
|
|
not set any ingress/egress permissions as Elastic Beanstalk will create
|
|
these for us. This group will be attached to our EC2 instances, and the
|
|
RDS instance will permit incoming traffic from this group only.
|
|
VpcId: !Ref PublicVPC
|
|
PublicSubnet0:
|
|
Type: AWS::EC2::Subnet
|
|
Properties:
|
|
AvailabilityZone:
|
|
Fn::Select:
|
|
- 0
|
|
- Fn::GetAZs: !Ref "AWS::Region"
|
|
VpcId: !Ref PublicVPC
|
|
CidrBlock: 172.31.0.0/20
|
|
MapPublicIpOnLaunch: true
|
|
PublicSubnet1:
|
|
Type: AWS::EC2::Subnet
|
|
Properties:
|
|
AvailabilityZone:
|
|
Fn::Select:
|
|
- 1
|
|
- Fn::GetAZs: !Ref "AWS::Region"
|
|
VpcId: !Ref PublicVPC
|
|
CidrBlock: 172.31.16.0/20
|
|
MapPublicIpOnLaunch: true
|
|
PublicSubnet2:
|
|
Type: AWS::EC2::Subnet
|
|
Properties:
|
|
AvailabilityZone:
|
|
Fn::Select:
|
|
- 2
|
|
- Fn::GetAZs: !Ref "AWS::Region"
|
|
VpcId: !Ref PublicVPC
|
|
CidrBlock: 172.31.32.0/20
|
|
MapPublicIpOnLaunch: true
|
|
InternetGateway:
|
|
Type: AWS::EC2::InternetGateway
|
|
InternetGatewayAttachment:
|
|
Type: AWS::EC2::VPCGatewayAttachment
|
|
Properties:
|
|
VpcId: !Ref PublicVPC
|
|
InternetGatewayId: !Ref InternetGateway
|
|
PublicRouteTable:
|
|
Type: AWS::EC2::RouteTable
|
|
Properties:
|
|
VpcId: !Ref PublicVPC
|
|
PublicRoute:
|
|
Type: AWS::EC2::Route
|
|
DependsOn: InternetGatewayAttachment
|
|
Properties:
|
|
RouteTableId: !Ref PublicRouteTable
|
|
DestinationCidrBlock: 0.0.0.0/0
|
|
GatewayId: !Ref InternetGateway
|
|
PublicSubnet0RouteTableAssociation:
|
|
Type: AWS::EC2::SubnetRouteTableAssociation
|
|
Properties:
|
|
SubnetId: !Ref PublicSubnet0
|
|
RouteTableId: !Ref PublicRouteTable
|
|
PublicSubnet1RouteTableAssociation:
|
|
Type: AWS::EC2::SubnetRouteTableAssociation
|
|
Properties:
|
|
SubnetId: !Ref PublicSubnet1
|
|
RouteTableId: !Ref PublicRouteTable
|
|
PublicSubnet2RouteTableAssociation:
|
|
Type: AWS::EC2::SubnetRouteTableAssociation
|
|
Properties:
|
|
SubnetId: !Ref PublicSubnet2
|
|
RouteTableId: !Ref PublicRouteTable
|
|
Outputs:
|
|
PublicVPCID:
|
|
Description: The VPC ID.
|
|
Value: !Ref PublicVPC
|
|
Export:
|
|
Name: !Sub "${AWS::StackName}-PublicVPC"
|
|
PublicSecurityGroupId:
|
|
Description: The EC2 security group ID.
|
|
Value: !Ref PublicSecurityGroup
|
|
Export:
|
|
Name: !Sub "${AWS::StackName}-PublicSecurityGroup"
|
|
PublicVPCIDDefaultSecurityGroup:
|
|
Description: The VPC default security group.
|
|
Value: !GetAtt PublicVPC.DefaultSecurityGroup
|
|
Export:
|
|
Name: !Sub "${AWS::StackName}-PublicVPCIDDefaultSecurityGroup"
|
|
PublicSubnet0ID:
|
|
Description: The ID of the subnet.
|
|
Value: !Ref PublicSubnet0
|
|
Export:
|
|
Name: !Sub "${AWS::StackName}-PublicSubnet0"
|
|
PublicSubnet1ID:
|
|
Description: The ID of the subnet.
|
|
Value: !Ref PublicSubnet1
|
|
Export:
|
|
Name: !Sub "${AWS::StackName}-PublicSubnet1"
|
|
PublicSubnet2ID:
|
|
Description: The ID of the subnet.
|
|
Value: !Ref PublicSubnet2
|
|
Export:
|
|
Name: !Sub "${AWS::StackName}-PublicSubnet2"
|