Last active
July 10, 2017 04:50
-
-
Save Tmorinaga/e606d21c0ae1298fec7806dd6c5f0f8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
AWSTemplateFormatVersion: '2010-09-09' | |
Description: VPC Template | |
Parameters: | |
NameTagPrefix: | |
Type: String | |
Description: Prefix of Name tags. | |
Mappings: | |
StackConfig: | |
VPC: | |
CIDR: 10.0.0.0/16 | |
FrontendSubnet1: | |
CIDR: 10.0.0.0/24 | |
FrontendSubnet2: | |
CIDR: 10.0.1.0/24 | |
ApplicationSubnet1: | |
CIDR: 10.0.10.0/24 | |
ApplicationSubnet2: | |
CIDR: 10.0.11.0/24 | |
DatastoreSubnet1: | |
CIDR: 10.0.30.0/24 | |
DatastoreSubnet2: | |
CIDR: 10.0.31.0/24 | |
Resources: | |
VPC: | |
Type: AWS::EC2::VPC | |
Properties: | |
CidrBlock: !FindInMap [ StackConfig, VPC, CIDR ] | |
InstanceTenancy: default | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, VPC ] ] | |
InternetGateway: | |
Type: AWS::EC2::InternetGateway | |
Properties: | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, IGW ] ] | |
AttachGateway: | |
Type: AWS::EC2::VPCGatewayAttachment | |
Properties: | |
VpcId: !Ref VPC | |
InternetGatewayId: !Ref InternetGateway | |
FrontendRouteTable: | |
Type: AWS::EC2::RouteTable | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: | |
Ref: VPC | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, FrontendRoute ] ] | |
FrontendRoute: | |
Type: AWS::EC2::Route | |
DependsOn: AttachGateway | |
Properties: | |
RouteTableId: !Ref FrontendRouteTable | |
DestinationCidrBlock: 0.0.0.0/0 | |
GatewayId: !Ref InternetGateway | |
ApplicationRouteTable: | |
Type: AWS::EC2::RouteTable | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, ApplicationRoute ] ] | |
ApplicationRoute: | |
Type: AWS::EC2::Route | |
DependsOn: AttachGateway | |
Properties: | |
RouteTableId: !Ref ApplicationRouteTable | |
DestinationCidrBlock: 0.0.0.0/0 | |
GatewayId: !Ref InternetGateway | |
DatastoreRouteTable: | |
Type: AWS::EC2::RouteTable | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, DatastoreRoute ] ] | |
FrontendSubnet1: | |
Type: AWS::EC2::Subnet | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
AvailabilityZone: !Select | |
- '0' | |
- Fn::GetAZs: !Ref AWS::Region | |
CidrBlock: !FindInMap [ StackConfig, FrontendSubnet1, CIDR ] | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, FrontendSubnet1 ] ] | |
FrontendSubnet1RouteTableAssociation: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
SubnetId: !Ref FrontendSubnet1 | |
RouteTableId: !Ref FrontendRouteTable | |
FrontendSubnet2: | |
Type: AWS::EC2::Subnet | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
AvailabilityZone: !Select | |
- '1' | |
- Fn::GetAZs: !Ref AWS::Region | |
CidrBlock: !FindInMap [ StackConfig, FrontendSubnet2, CIDR ] | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, FrontendSubnet2 ] ] | |
FrontendSubnet2RouteTableAssociation: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
SubnetId: !Ref FrontendSubnet2 | |
RouteTableId: !Ref FrontendRouteTable | |
ApplicationSubnet1: | |
Type: AWS::EC2::Subnet | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
AvailabilityZone: !Select | |
- '0' | |
- Fn::GetAZs: !Ref AWS::Region | |
CidrBlock: !FindInMap [ StackConfig, ApplicationSubnet1, CIDR ] | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, ApplicationSubnet1 ] ] | |
ApplicationSubnet1RouteTableAssociation: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
SubnetId: !Ref ApplicationSubnet1 | |
RouteTableId: !Ref ApplicationRouteTable | |
ApplicationSubnet2: | |
Type: AWS::EC2::Subnet | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
AvailabilityZone: !Select | |
- '1' | |
- Fn::GetAZs: !Ref AWS::Region | |
CidrBlock: !FindInMap [ StackConfig, ApplicationSubnet2, CIDR ] | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, ApplicationSubnet2 ] ] | |
ApplicationSubnet2RouteTableAssociation: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
SubnetId: !Ref ApplicationSubnet2 | |
RouteTableId: !Ref ApplicationRouteTable | |
DatastoreSubnet1: | |
Type: AWS::EC2::Subnet | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
AvailabilityZone: !Select | |
- '0' | |
- Fn::GetAZs: !Ref AWS::Region | |
CidrBlock: | |
Fn::FindInMap: | |
- StackConfig | |
- DatastoreSubnet1 | |
- CIDR | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, DatastoreSubnet1 ] ] | |
DatastoreSubnet1RouteTableAssociation: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
SubnetId: !Ref DatastoreSubnet1 | |
RouteTableId: !Ref DatastoreRouteTable | |
DatastoreSubnet2: | |
Type: AWS::EC2::Subnet | |
DependsOn: AttachGateway | |
Properties: | |
VpcId: !Ref VPC | |
AvailabilityZone: !Select | |
- '1' | |
- Fn::GetAZs: !Ref AWS::Region | |
CidrBlock: | |
Fn::FindInMap: | |
- StackConfig | |
- DatastoreSubnet2 | |
- CIDR | |
Tags: | |
- Key: Name | |
Value: !Join [ '-', [ !Ref NameTagPrefix, DatastoreSubnet2 ] ] | |
DatastoreSubnet2RouteTableAssociation: | |
Type: AWS::EC2::SubnetRouteTableAssociation | |
Properties: | |
SubnetId: !Ref DatastoreSubnet2 | |
RouteTableId: !Ref DatastoreRouteTable | |
Outputs: | |
VPC: | |
Value: !Ref VPC | |
FrontendSubnet1: | |
Value: !Ref FrontendSubnet1 | |
FrontendSubnet2: | |
Value: !Ref FrontendSubnet2 | |
ApplicationSubnet1: | |
Value: !Ref ApplicationSubnet1 | |
ApplicationSubnet2: | |
Value: !Ref ApplicationSubnet2 | |
DatastoreSubnet1: | |
Value: !Ref DatastoreSubnet1 | |
DatastoreSubnet2: | |
Value: !Ref DatastoreSubnet2 | |
FrontendRouteTable: | |
Value: !Ref FrontendRouteTable | |
ApplicationRouteTable: | |
Value: !Ref ApplicationRouteTable | |
DatastoreRouteTable: | |
Value: !Ref DatastoreRouteTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment