Guest User

Untitled

a guest
Jul 15th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. #Dynamic az's
  2. Resources:
  3. PubPrivateVPC:
  4. Type: 'AWS::EC2::VPC'
  5. Properties:
  6. CidrBlock: 172.31.0.0/16
  7.  
  8. PublicSubnet1:
  9. Type: 'AWS::EC2::Subnet'
  10. Properties:
  11. VpcId: !Ref PubPrivateVPC
  12. AvailabilityZone: us-east-1a
  13. CidrBlock: 172.31.1.0/24
  14. MapPublicIpOnLaunch: true
  15.  
  16. PublicSubnet2:
  17. Type: 'AWS::EC2::Subnet'
  18. Properties:
  19. VpcId: !Ref PubPrivateVPC
  20. AvailabilityZone: us-east-1b
  21. CidrBlock: 172.31.2.0/24
  22. MapPublicIpOnLaunch: true
  23.  
  24. PrivateSubnet1:
  25. Type: 'AWS::EC2::Subnet'
  26. Properties:
  27. VpcId: !Ref PubPrivateVPC
  28. AvailabilityZone: us-east-1a
  29. CidrBlock: 172.31.3.0/24
  30. MapPublicIpOnLaunch: false
  31.  
  32. PrivateSubnet2:
  33. Type: 'AWS::EC2::Subnet'
  34. Properties:
  35. VpcId: !Ref PubPrivateVPC
  36. AvailabilityZone: us-east-1b
  37. CidrBlock: 172.31.4.0/24
  38. MapPublicIpOnLaunch: false
  39.  
  40.  
  41. InternetGateway:
  42. Type: 'AWS::EC2::InternetGateway'
  43. Properties:
  44. Tags:
  45. - Key: Name
  46. Value: !Join [_, [!Ref 'AWS::StackName']]
  47. - Key: Network
  48. Value: Public
  49.  
  50. GatewayToInternet:
  51. Type: 'AWS::EC2::VPCGatewayAttachment'
  52. Properties:
  53. VpcId: !Ref PubPrivateVPC
  54. InternetGatewayId: !Ref InternetGateway
  55.  
  56. PublicRouteTable:
  57. Type: 'AWS::EC2::RouteTable'
  58. Properties:
  59. VpcId: !Ref PubPrivateVPC
  60. Tags:
  61. - Key: Network
  62. Value: Public
  63.  
  64. PublicRoute:
  65. Type: 'AWS::EC2::Route'
  66. DependsOn: GatewayToInternet
  67. Properties:
  68. RouteTableId: !Ref PublicRouteTable
  69. DestinationCidrBlock: 0.0.0.0/0
  70. GatewayId: !Ref InternetGateway
  71.  
  72. PublicSubnet1RouteTableAssociation:
  73. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  74. Properties:
  75. SubnetId: !Ref PublicSubnet1
  76. RouteTableId: !Ref PublicRouteTable
  77.  
  78. PublicSubnet2RouteTableAssociation:
  79. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  80. Properties:
  81. SubnetId: !Ref PublicSubnet2
  82. RouteTableId: !Ref PublicRouteTable
  83.  
  84. NatGateway:
  85. Type: "AWS::EC2::NatGateway"
  86. DependsOn: NatPublicIP
  87. Properties:
  88. AllocationId: !GetAtt NatPublicIP.AllocationId
  89. SubnetId: !Ref PublicSubnet1
  90.  
  91. NatPublicIP:
  92. Type: "AWS::EC2::EIP"
  93. DependsOn: PubPrivateVPC
  94. Properties:
  95. Domain: vpc
  96.  
  97. PrivateRouteTable:
  98. Type: 'AWS::EC2::RouteTable'
  99. Properties:
  100. VpcId: !Ref PubPrivateVPC
  101. Tags:
  102. - Key: Network
  103. Value: Private
  104.  
  105. PrivateRoute:
  106. Type: 'AWS::EC2::Route'
  107. Properties:
  108. RouteTableId: !Ref PrivateRouteTable
  109. DestinationCidrBlock: 0.0.0.0/0
  110. NatGatewayId: !Ref NatGateway
  111.  
  112. PrivateSubnet1RouteTableAssociation:
  113. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  114. Properties:
  115. SubnetId: !Ref PrivateSubnet1
  116. RouteTableId: !Ref PrivateRouteTable
  117.  
  118. PrivateSubnet2RouteTableAssociation:
  119. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  120. Properties:
  121. SubnetId: !Ref PrivateSubnet2
  122. RouteTableId: !Ref PrivateRouteTable
Add Comment
Please, Sign In to add comment