Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
119 lines (101 sloc) 2.76 KB
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple VPC public network.
Parameters:
VpcCidrBlock:
Type: String
Description: VPC CIDR Block.
Default: 10.0.0.0/16
PublicSubnetACidrBlock:
Type: String
Description: PublicSubnetA CIDR Block.
Default: 10.0.1.0/24
PublicSubnetCCidrBlock:
Type: String
Description: PublicSubnetC CIDR Block.
Default: 10.0.2.0/24
Resources:
Vpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidrBlock
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: default
PublicRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref Vpc
PublicSubnetA:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref Vpc
CidrBlock: !Ref PublicSubnetACidrBlock
AvailabilityZone: ap-northeast-1a
MapPublicIpOnLaunch: true
PubSubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnetA
RouteTableId: !Ref PublicRouteTable
PublicSubnetC:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref Vpc
CidrBlock: !Ref PublicSubnetCCidrBlock
AvailabilityZone: ap-northeast-1c
MapPublicIpOnLaunch: true
PubSubnetCRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref PublicSubnetC
RouteTableId: !Ref PublicRouteTable
InternetGateway:
Type: AWS::EC2::InternetGateway
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref Vpc
InternetGatewayId: !Ref InternetGateway
InternetRoute:
Type: AWS::EC2::Route
DependsOn: InternetGateway
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SecurityGroup for ECS VPC
VpcId: !Ref Vpc
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
IpProtocol: tcp
FromPort: 0
ToPort: 65535
SecurityGroupEgress:
- CidrIp: 0.0.0.0/0
IpProtocol: tcp
FromPort: 0
ToPort: 65535
Outputs:
VPCId:
Description: The ID of the VPC
Value: !Ref Vpc
Export:
Name: !Sub "${AWS::StackName}-VPCID"
PublicSubnetA:
Description: The ID of the VPC Subnet
Value: !Ref PublicSubnetA
Export:
Name: !Sub "${AWS::StackName}-PublicSubnetA"
PublicSubnetB:
Description: The ID of the VPC Subnet
Value: !Ref PublicSubnetC
Export:
Name: !Sub "${AWS::StackName}-PublicSubnetC"
SecurityGroup:
Description: The ID of the SecurityGroup
Value: !Ref SecurityGroup
Export:
Name: !Sub "${AWS::StackName}-SecurityGroup"