Guest User

Untitled

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