Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- AWSTemplateFormatVersion: '2010-09-09'
- Description: '2AZs (pub+priv) (based on cloudonaut.io template)'
- # Invoke with
- # aws cloudformation create-stack --stack-name <name> --template-body https://pastebin.com/raw/<id> --parameters ParameterKey=Owner,ParameterValue=<owner> ParameterKey=ClassB,ParameterValue=10 --profile awslabs
- Metadata:
- 'AWS::CloudFormation::Interface':
- ParameterGroups:
- - Label:
- default: 'VPC Parameters'
- Parameters:
- - ClassB
- Parameters:
- ClassB:
- Description: 'Class B of VPC (10.XXX.0.0/16)'
- Type: Number
- Default: 0
- ConstraintDescription: 'Must be in the range [0-255]'
- MinValue: 0
- MaxValue: 255
- Owner:
- Description: 'Owner of the resources.'
- Type: String
- Resources:
- VPC:
- Type: 'AWS::EC2::VPC'
- Properties:
- CidrBlock: !Sub '10.${ClassB}.0.0/16'
- EnableDnsSupport: true
- EnableDnsHostnames: true
- InstanceTenancy: default
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-vpc-${ClassB}'
- - Key: Owner
- Value: !Sub '${Owner}'
- InternetGateway:
- Type: 'AWS::EC2::InternetGateway'
- Properties:
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-igw-${ClassB}'
- - Key: Owner
- Value: !Sub '${Owner}'
- VPCGatewayAttachment:
- Type: 'AWS::EC2::VPCGatewayAttachment'
- Properties:
- VpcId: !Ref VPC
- InternetGatewayId: !Ref InternetGateway
- SubnetAPublic:
- Type: 'AWS::EC2::Subnet'
- Properties:
- AvailabilityZone: !Select [0, !GetAZs '']
- CidrBlock: !Sub '10.${ClassB}.0.0/20'
- MapPublicIpOnLaunch: true
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-sub-${ClassB}-A public'
- - Key: Reach
- Value: public
- - Key: Owner
- Value: !Sub '${Owner}'
- SubnetAPrivate:
- Type: 'AWS::EC2::Subnet'
- Properties:
- AvailabilityZone: !Select [0, !GetAZs '']
- CidrBlock: !Sub '10.${ClassB}.16.0/20'
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-sub-${ClassB}-A private'
- - Key: Reach
- Value: private
- - Key: Owner
- Value: !Sub '${Owner}'
- SubnetBPublic:
- Type: 'AWS::EC2::Subnet'
- Properties:
- AvailabilityZone: !Select [1, !GetAZs '']
- CidrBlock: !Sub '10.${ClassB}.32.0/20'
- MapPublicIpOnLaunch: true
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-sub-${ClassB}-B public'
- - Key: Reach
- Value: public
- - Key: Owner
- Value: !Sub '${Owner}'
- SubnetBPrivate:
- Type: 'AWS::EC2::Subnet'
- Properties:
- AvailabilityZone: !Select [1, !GetAZs '']
- CidrBlock: !Sub '10.${ClassB}.48.0/20'
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-sub-${ClassB}-B private'
- - Key: Reach
- Value: private
- - Key: Owner
- Value: !Sub '${Owner}'
- RouteTablePublic:
- Type: 'AWS::EC2::RouteTable'
- Properties:
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-rt-${ClassB}-public'
- - Key: Owner
- Value: !Sub '${Owner}'
- RouteTablePrivate:
- Type: 'AWS::EC2::RouteTable'
- Properties:
- VpcId: !Ref VPC
- Tags:
- - Key: Name
- Value: !Sub '${Owner}-rt-${ClassB}-private'
- - Key: Owner
- Value: !Sub '${Owner}'
- RouteTableAssociationAPublic:
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- Properties:
- SubnetId: !Ref SubnetAPublic
- RouteTableId: !Ref RouteTablePublic
- RouteTableAssociationAPrivate:
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- Properties:
- SubnetId: !Ref SubnetAPrivate
- RouteTableId: !Ref RouteTablePrivate
- RouteTableAssociationBPublic:
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- Properties:
- SubnetId: !Ref SubnetBPublic
- RouteTableId: !Ref RouteTablePublic
- RouteTableAssociationBPrivate:
- Type: 'AWS::EC2::SubnetRouteTableAssociation'
- Properties:
- SubnetId: !Ref SubnetBPrivate
- RouteTableId: !Ref RouteTablePrivate
- RouteTablePublicInternetRoute:
- Type: 'AWS::EC2::Route'
- DependsOn: VPCGatewayAttachment
- Properties:
- RouteTableId: !Ref RouteTablePublic
- DestinationCidrBlock: '0.0.0.0/0'
- GatewayId: !Ref InternetGateway
- Outputs:
- TemplateID:
- Description: 'cloudonaut.io template id'
- Value: 'vpc/vpc-2azs'
- StackName:
- Description: 'Stack name'
- Value: !Sub '${AWS::StackName}'
- AZs:
- Description: 'AZs'
- Value: 2
- Export:
- Name: !Sub '${AWS::StackName}-AZs'
- AZA:
- Description: 'AZ of A'
- Value: !Select [0, !GetAZs '']
- Export:
- Name: !Sub '${AWS::StackName}-AZA'
- AZB:
- Description: 'AZ of B'
- Value: !Select [1, !GetAZs '']
- Export:
- Name: !Sub '${AWS::StackName}-AZB'
- ClassB:
- Description: 'Class B.'
- Value: !Ref ClassB
- Export:
- Name: !Sub '${AWS::StackName}-ClassB'
- VPC:
- Description: 'VPC.'
- Value: !Ref VPC
- Export:
- Name: !Sub '${AWS::StackName}-VPC'
- SubnetsPublic:
- Description: 'Subnets public.'
- Value: !Join [',', [!Ref SubnetAPublic, !Ref SubnetBPublic]]
- Export:
- Name: !Sub '${AWS::StackName}-SubnetsPublic'
- SubnetsPrivate:
- Description: 'Subnets private.'
- Value: !Join [',', [!Ref SubnetAPrivate, !Ref SubnetBPrivate]]
- Export:
- Name: !Sub '${AWS::StackName}-SubnetsPrivate'
- SubnetAPublic:
- Description: 'Subnet A public.'
- Value: !Ref SubnetAPublic
- Export:
- Name: !Sub '${AWS::StackName}-SubnetAPublic'
- SubnetPrivate:
- Description: 'Subnet A private.'
- Value: !Ref SubnetAPrivate
- Export:
- Name: !Sub '${AWS::StackName}-SubnetAPrivate'
- SubnetBPublic:
- Description: 'Subnet B public.'
- Value: !Ref SubnetBPublic
- Export:
- Name: !Sub '${AWS::StackName}-SubnetBPublic'
- SubnetBPrivate:
- Description: 'Subnet B private.'
- Value: !Ref SubnetBPrivate
- Export:
- Name: !Sub '${AWS::StackName}-SubnetBPrivate'
- RouteTablePrivate:
- Description: 'Route table private (deprecated in v4, will be removed in v5).'
- Value: !Ref RouteTablePrivate
- Export:
- Name: !Sub '${AWS::StackName}-RouteTablePrivate'
- RouteTablePublic:
- Description: 'Route table public (deprecated in v4, will be removed in v5).'
- Value: !Ref RouteTablePublic
- Export:
- Name: !Sub '${AWS::StackName}-RouteTablePublic'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement