vpc.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. AWSTemplateFormatVersion: 2010-09-09
  2. Resources:
  3. vpc1:
  4. Type: 'AWS::EC2::VPC'
  5. Properties:
  6. CidrBlock: !Ref vpccidr
  7. EnableDnsHostnames: 'true'
  8. EnableDnsSupport: 'true'
  9. Tags:
  10. - Key: Name
  11. Value: vpc1
  12. Metadata:
  13. 'AWS::CloudFormation::Designer':
  14. id: 36050a81-2f2b-4482-9d6a-763dbad1b527
  15. pubnet1:
  16. Type: 'AWS::EC2::Subnet'
  17. Properties:
  18. AvailabilityZone: !Select
  19. - '0'
  20. - !GetAZs ''
  21. CidrBlock: !Ref pubnet1cidr
  22. Tags:
  23. - Key: Name
  24. Value: pubnet1
  25. VpcId: !Ref vpc1
  26. Metadata:
  27. 'AWS::CloudFormation::Designer':
  28. id: d00fad60-d71a-4bfc-988a-65236dea5a6f
  29. pubnet2:
  30. Type: 'AWS::EC2::Subnet'
  31. Properties:
  32. AvailabilityZone: !Select
  33. - '1'
  34. - !GetAZs ''
  35. CidrBlock: !Ref pubnet2cidr
  36. Tags:
  37. - Key: Name
  38. Value: pubnet2
  39. VpcId: !Ref vpc1
  40. Metadata:
  41. 'AWS::CloudFormation::Designer':
  42. id: dbc87cce-6f33-46fb-8684-24fc5008ad91
  43. webnet1:
  44. Type: 'AWS::EC2::Subnet'
  45. Properties:
  46. AvailabilityZone: !Select
  47. - '0'
  48. - !GetAZs ''
  49. CidrBlock: !Ref webnet1cidr
  50. Tags:
  51. - Key: Name
  52. Value: webnet1
  53. VpcId: !Ref vpc1
  54. Metadata:
  55. 'AWS::CloudFormation::Designer':
  56. id: 30f1713d-c319-4dcb-8730-c4baf0cb207a
  57. webnet2:
  58. Type: 'AWS::EC2::Subnet'
  59. Properties:
  60. AvailabilityZone: !Select
  61. - '1'
  62. - !GetAZs ''
  63. CidrBlock: !Ref webnet2cidr
  64. Tags:
  65. - Key: Name
  66. Value: webnet2
  67. VpcId: !Ref vpc1
  68. Metadata:
  69. 'AWS::CloudFormation::Designer':
  70. id: bd5423c4-721b-4194-a7ba-b8d4b437683a
  71. dbnet1:
  72. Type: 'AWS::EC2::Subnet'
  73. Properties:
  74. AvailabilityZone: !Select
  75. - '0'
  76. - !GetAZs ''
  77. CidrBlock: !Ref dbnet1cidr
  78. Tags:
  79. - Key: Name
  80. Value: dbnet1
  81. VpcId: !Ref vpc1
  82. Metadata:
  83. 'AWS::CloudFormation::Designer':
  84. id: d721de76-5cf2-416c-985d-2bd9d10d4c3c
  85. dbnet2:
  86. Type: 'AWS::EC2::Subnet'
  87. Properties:
  88. AvailabilityZone: !Select
  89. - '1'
  90. - !GetAZs ''
  91. CidrBlock: !Ref dbnet2cidr
  92. Tags:
  93. - Key: Name
  94. Value: dbnet2
  95. VpcId: !Ref vpc1
  96. Metadata:
  97. 'AWS::CloudFormation::Designer':
  98. id: d3655dff-3e6c-4e71-b429-782c249ead24
  99. table1:
  100. Type: 'AWS::EC2::RouteTable'
  101. Properties:
  102. Tags:
  103. - Key: Name
  104. Value: table1
  105. VpcId: !Ref vpc1
  106. Metadata:
  107. 'AWS::CloudFormation::Designer':
  108. id: 5a28c477-28f7-4f63-96e4-eba4f2af91c8
  109. table2:
  110. Type: 'AWS::EC2::RouteTable'
  111. Properties:
  112. Tags:
  113. - Key: Name
  114. Value: table2
  115. VpcId: !Ref vpc1
  116. Metadata:
  117. 'AWS::CloudFormation::Designer':
  118. id: e7cb3a54-60cc-4806-b6c5-51dd541555b2
  119. table3:
  120. Type: 'AWS::EC2::RouteTable'
  121. Properties:
  122. Tags:
  123. - Key: Name
  124. Value: table3
  125. VpcId: !Ref vpc1
  126. Metadata:
  127. 'AWS::CloudFormation::Designer':
  128. id: b031b8a3-c571-4e9b-967f-e777ca927d08
  129. igw1:
  130. Type: 'AWS::EC2::InternetGateway'
  131. Properties: {}
  132. Metadata:
  133. 'AWS::CloudFormation::Designer':
  134. id: 4f2d896c-333a-4e40-acf1-a4d29c7f1e04
  135. EC2VPCG2BPGG:
  136. Type: 'AWS::EC2::VPCGatewayAttachment'
  137. Properties:
  138. InternetGatewayId: !Ref igw1
  139. VpcId: !Ref vpc1
  140. Metadata:
  141. 'AWS::CloudFormation::Designer':
  142. id: 544c5488-107f-4d4f-99d7-f22003afd889
  143. natgateway1:
  144. Type: 'AWS::EC2::NatGateway'
  145. Properties:
  146. AllocationId: !GetAtt
  147. - eip1
  148. - AllocationId
  149. SubnetId: !Ref pubnet1
  150. Metadata:
  151. 'AWS::CloudFormation::Designer':
  152. id: df5bea53-45ac-47d0-ae9e-32e7d54a37a5
  153. natgateway2:
  154. Type: 'AWS::EC2::NatGateway'
  155. Properties:
  156. AllocationId: !GetAtt
  157. - eip2
  158. - AllocationId
  159. SubnetId: !Ref pubnet2
  160. Metadata:
  161. 'AWS::CloudFormation::Designer':
  162. id: b8570bf1-7fe5-4d58-8fb9-83e3660f2170
  163. eip1:
  164. Type: 'AWS::EC2::EIP'
  165. Properties: {}
  166. Metadata:
  167. 'AWS::CloudFormation::Designer':
  168. id: d77dbe47-fc90-4338-8ff2-af4000405dde
  169. eip2:
  170. Type: 'AWS::EC2::EIP'
  171. Properties: {}
  172. Metadata:
  173. 'AWS::CloudFormation::Designer':
  174. id: e8777cd9-8375-401a-ad6f-52051c09dc89
  175. EC2SRTA51E2B:
  176. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  177. Properties:
  178. SubnetId: !Ref pubnet1
  179. RouteTableId: !Ref table1
  180. Metadata:
  181. 'AWS::CloudFormation::Designer':
  182. id: 72574f43-a5f8-4c3b-bcf7-f8b199887e9c
  183. EC2SRTA2YHOD:
  184. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  185. Properties:
  186. SubnetId: !Ref pubnet2
  187. RouteTableId: !Ref table1
  188. Metadata:
  189. 'AWS::CloudFormation::Designer':
  190. id: f7e5fe7c-a1c1-48e0-8743-daa1f0e3fb06
  191. EC2SRTA2VWB8:
  192. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  193. Properties:
  194. RouteTableId: !Ref table2
  195. SubnetId: !Ref webnet1
  196. Metadata:
  197. 'AWS::CloudFormation::Designer':
  198. id: 5b9f52cd-7dd4-4a0e-88d2-ebd48368e2a4
  199. EC2SRTA26CTN:
  200. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  201. Properties:
  202. SubnetId: !Ref dbnet1
  203. RouteTableId: !Ref table2
  204. Metadata:
  205. 'AWS::CloudFormation::Designer':
  206. id: 3cedd898-d918-44c1-938d-cfc6512301ea
  207. EC2SRTAH6LA:
  208. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  209. Properties:
  210. SubnetId: !Ref webnet2
  211. RouteTableId: !Ref table3
  212. Metadata:
  213. 'AWS::CloudFormation::Designer':
  214. id: 91524a30-078a-41c2-a34e-0f16b37b3691
  215. EC2SRTA1VSM:
  216. Type: 'AWS::EC2::SubnetRouteTableAssociation'
  217. Properties:
  218. SubnetId: !Ref dbnet2
  219. RouteTableId: !Ref table3
  220. Metadata:
  221. 'AWS::CloudFormation::Designer':
  222. id: 1220e1c3-e8c3-4f7a-998d-e60203564b8d
  223. route1:
  224. Type: 'AWS::EC2::Route'
  225. Properties:
  226. DestinationCidrBlock: 0.0.0.0/0
  227. GatewayId: !Ref igw1
  228. RouteTableId: !Ref table1
  229. Metadata:
  230. 'AWS::CloudFormation::Designer':
  231. id: d037ea69-ec83-4c36-92f7-12c199349fd9
  232. route2:
  233. Type: 'AWS::EC2::Route'
  234. Properties:
  235. DestinationCidrBlock: 0.0.0.0/0
  236. NatGatewayId: !Ref natgateway1
  237. RouteTableId: !Ref table2
  238. Metadata:
  239. 'AWS::CloudFormation::Designer':
  240. id: 64d213ca-d8f7-45f3-a53b-6001ad55ba0a
  241. route3:
  242. Type: 'AWS::EC2::Route'
  243. Properties:
  244. DestinationCidrBlock: 0.0.0.0/0
  245. NatGatewayId: !Ref natgateway2
  246. RouteTableId: !Ref table3
  247. Metadata:
  248. 'AWS::CloudFormation::Designer':
  249. id: c5cec4ea-e367-424f-9e78-92220722b760
  250. elbgroup:
  251. Type: 'AWS::EC2::SecurityGroup'
  252. Properties:
  253. GroupDescription: sg_elb
  254. GroupName: sg_elb
  255. Tags:
  256. - Key: Name
  257. Value: sg_elb
  258. SecurityGroupIngress:
  259. - IpProtocol: tcp
  260. FromPort: 80
  261. ToPort: 80
  262. CidrIp: 0.0.0.0/0
  263. SecurityGroupEgress:
  264. - CidrIp: 0.0.0.0/0
  265. IpProtocol: '-1'
  266. VpcId: !Ref vpc1
  267. Metadata:
  268. 'AWS::CloudFormation::Designer':
  269. id: 41ff46eb-edb8-456f-9183-4d7eea31e49a
  270. webgroup:
  271. Type: 'AWS::EC2::SecurityGroup'
  272. Properties:
  273. GroupDescription: !Ref sgName
  274. GroupName: !Ref sgName
  275. Tags:
  276. - Key: Name
  277. Value: !Ref sgName
  278. SecurityGroupIngress:
  279. - IpProtocol: tcp
  280. FromPort: 7777
  281. ToPort: 7777
  282. CidrIp: 0.0.0.0/0
  283. - IpProtocol: tcp
  284. FromPort: 22
  285. ToPort: 22
  286. CidrIp: 0.0.0.0/0
  287. SecurityGroupEgress:
  288. - CidrIp: 0.0.0.0/0
  289. IpProtocol: '-1'
  290. VpcId: !Ref vpc1
  291. Metadata:
  292. 'AWS::CloudFormation::Designer':
  293. id: 3d3c83e4-c428-4628-a0e2-d4415ec6cfd6
  294. dbgroup:
  295. Type: 'AWS::EC2::SecurityGroup'
  296. Properties:
  297. GroupDescription: dbgroup
  298. GroupName: elasticache_memcache
  299. Tags:
  300. - Key: Name
  301. Value: elasticache_memcache
  302. SecurityGroupIngress:
  303. - SourceSecurityGroupId: !Ref webgroup
  304. FromPort: !Ref cacheport
  305. ToPort: !Ref cacheport
  306. IpProtocol: tcp
  307. - SourceSecurityGroupId: !Ref webgroup
  308. FromPort: '2049'
  309. ToPort: '2049'
  310. IpProtocol: tcp
  311. - SourceSecurityGroupId: !Ref webgroup
  312. FromPort: '5432'
  313. ToPort: '5432'
  314. IpProtocol: tcp
  315. SecurityGroupEgress:
  316. - CidrIp: 0.0.0.0/0
  317. IpProtocol: '-1'
  318. VpcId: !Ref vpc1
  319. Metadata:
  320. 'AWS::CloudFormation::Designer':
  321. id: a2a71bad-d448-4630-ae7a-ac51d0366306
  322. cachegroup:
  323. Type: 'AWS::ElastiCache::SubnetGroup'
  324. Properties:
  325. CacheSubnetGroupName: cachegroup
  326. Description: cachegroup
  327. SubnetIds:
  328. - !Ref dbnet1
  329. - !Ref dbnet2
  330. Metadata:
  331. 'AWS::CloudFormation::Designer':
  332. id: 4c252f4a-8901-40df-b0a2-386cee29c258
  333. rdsgroup:
  334. Type: 'AWS::RDS::DBSubnetGroup'
  335. Properties:
  336. DBSubnetGroupDescription: rdsgroup
  337. DBSubnetGroupName: rdsgroup
  338. Tags:
  339. - Key: Name
  340. Value: rdsgroup
  341. SubnetIds:
  342. - !Ref dbnet1
  343. - !Ref dbnet2
  344. Metadata:
  345. 'AWS::CloudFormation::Designer':
  346. id: 00338a06-280d-4c12-9255-b77136a19138
  347. Parameters:
  348. vpccidr:
  349. Type: String
  350. Default: 192.168.0.0/16
  351. pubnet1cidr:
  352. Type: String
  353. Default: 192.168.1.0/24
  354. pubnet2cidr:
  355. Type: String
  356. Default: 192.168.2.0/24
  357. webnet1cidr:
  358. Type: String
  359. Default: 192.168.3.0/24
  360. webnet2cidr:
  361. Type: String
  362. Default: 192.168.4.0/24
  363. dbnet1cidr:
  364. Type: String
  365. Default: 192.168.5.0/24
  366. dbnet2cidr:
  367. Type: String
  368. Default: 192.168.6.0/24
  369. cacheport:
  370. Type: String
  371. Default: '11211'
  372. sgName:
  373. Type: String
  374. Default: sg_ai
  375. Outputs:
  376. pubnet1id:
  377. Value: !Ref pubnet1
  378. pubnet2id:
  379. Value: !Ref pubnet2
  380. webnet1id:
  381. Value: !Ref webnet1
  382. webnet2id:
  383. Value: !Ref webnet2
  384. dbnet1id:
  385. Value: !Ref dbnet1
  386. dbnet2id:
  387. Value: !Ref dbnet2
  388. vpcid:
  389. Value: !Ref vpc1
  390. elbsg:
  391. Value: !Ref elbgroup
  392. serversg:
  393. Value: !Ref webgroup
  394. dbsg:
  395. Value: !Ref dbgroup