vpc-v2.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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: 6efe5731-b5ea-4e23-9b48-1353eaea32a1
  322. redissg:
  323. Type: 'AWS::EC2::SecurityGroup'
  324. Properties:
  325. GroupDescription: redissg
  326. GroupName: elasticache_redis
  327. Tags:
  328. - Key: Name
  329. Value: elasticache_redis
  330. SecurityGroupIngress:
  331. - SourceSecurityGroupId: !Ref webgroup
  332. FromPort: '6379'
  333. ToPort: '6379'
  334. IpProtocol: tcp
  335. - SourceSecurityGroupId: !Ref webgroup
  336. FromPort: '2049'
  337. ToPort: '2049'
  338. IpProtocol: tcp
  339. SecurityGroupEgress:
  340. - CidrIp: 0.0.0.0/0
  341. IpProtocol: '-1'
  342. VpcId: !Ref vpc1
  343. Metadata:
  344. 'AWS::CloudFormation::Designer':
  345. id: e2fe8abf-7e4a-472a-88e6-52c5b75b9924
  346. efssg:
  347. Type: 'AWS::EC2::SecurityGroup'
  348. Properties:
  349. GroupDescription: sgefs
  350. GroupName: sg_efs
  351. Tags:
  352. - Key: Name
  353. Value: sg_efs
  354. SecurityGroupIngress:
  355. - SourceSecurityGroupId: !Ref webgroup
  356. FromPort: '2049'
  357. ToPort: '2049'
  358. IpProtocol: tcp
  359. - SourceSecurityGroupId: !Ref lambdasg
  360. FromPort: '2049'
  361. ToPort: '2049'
  362. IpProtocol: tcp
  363. SecurityGroupEgress:
  364. - CidrIp: 0.0.0.0/0
  365. IpProtocol: '-1'
  366. VpcId: !Ref vpc1
  367. Metadata:
  368. 'AWS::CloudFormation::Designer':
  369. id: a2a71bad-d448-4630-ae7a-ac51d0366306
  370. cachegroup:
  371. Type: 'AWS::ElastiCache::SubnetGroup'
  372. Properties:
  373. CacheSubnetGroupName: cachegroup
  374. Description: cachegroup
  375. SubnetIds:
  376. - !Ref dbnet1
  377. - !Ref dbnet2
  378. Metadata:
  379. 'AWS::CloudFormation::Designer':
  380. id: 4c252f4a-8901-40df-b0a2-386cee29c258
  381. rdsgroup:
  382. Type: 'AWS::RDS::DBSubnetGroup'
  383. Properties:
  384. DBSubnetGroupDescription: rdsgroup
  385. DBSubnetGroupName: rdsgroup
  386. Tags:
  387. - Key: Name
  388. Value: rdsgroup
  389. SubnetIds:
  390. - !Ref dbnet1
  391. - !Ref dbnet2
  392. Metadata:
  393. 'AWS::CloudFormation::Designer':
  394. id: 00338a06-280d-4c12-9255-b77136a19138
  395. rdssg:
  396. Type: 'AWS::EC2::SecurityGroup'
  397. Properties:
  398. GroupDescription: sg_rds
  399. GroupName: sg_rds
  400. Tags:
  401. - Key: Name
  402. Value: sg_rds
  403. SecurityGroupIngress:
  404. - SourceSecurityGroupId: !Ref webgroup
  405. FromPort: '3306'
  406. ToPort: '3306'
  407. IpProtocol: tcp
  408. - SourceSecurityGroupId: !Ref webgroup
  409. FromPort: '5432'
  410. ToPort: '5432'
  411. IpProtocol: tcp
  412. - SourceSecurityGroupId: !Ref lambdasg
  413. FromPort: '5432'
  414. ToPort: '5432'
  415. IpProtocol: tcp
  416. - SourceSecurityGroupId: !Ref lambdasg
  417. FromPort: '3306'
  418. ToPort: '3306'
  419. IpProtocol: tcp
  420. SecurityGroupEgress:
  421. - CidrIp: 0.0.0.0/0
  422. IpProtocol: '-1'
  423. VpcId: !Ref vpc1
  424. Metadata:
  425. 'AWS::CloudFormation::Designer':
  426. id: 6efe5731-b5ea-4e23-9b48-1353eaea32a1
  427. lambdasg:
  428. Type: 'AWS::EC2::SecurityGroup'
  429. Properties:
  430. GroupDescription: sg_lambda
  431. GroupName: sg_lambda
  432. Tags:
  433. - Key: Name
  434. Value: sg_lambda
  435. SecurityGroupEgress:
  436. - CidrIp: 0.0.0.0/0
  437. IpProtocol: '-1'
  438. VpcId: !Ref vpc1
  439. Metadata:
  440. 'AWS::CloudFormation::Designer':
  441. id: 6efe5731-b5ea-4e23-9b48-1353eaea32a1
  442. Parameters:
  443. vpccidr:
  444. Type: String
  445. Default: 192.168.0.0/16
  446. pubnet1cidr:
  447. Type: String
  448. Default: 192.168.1.0/24
  449. pubnet2cidr:
  450. Type: String
  451. Default: 192.168.2.0/24
  452. webnet1cidr:
  453. Type: String
  454. Default: 192.168.3.0/24
  455. webnet2cidr:
  456. Type: String
  457. Default: 192.168.4.0/24
  458. dbnet1cidr:
  459. Type: String
  460. Default: 192.168.5.0/24
  461. dbnet2cidr:
  462. Type: String
  463. Default: 192.168.6.0/24
  464. cacheport:
  465. Type: String
  466. Default: '11211'
  467. sgName:
  468. Type: String
  469. Default: sg_ai
  470. Outputs:
  471. PUBnet1id:
  472. Value: !Ref pubnet1
  473. PUBnet2id:
  474. Value: !Ref pubnet2
  475. WEBbnet1id:
  476. Value: !Ref webnet1
  477. WEBnet2id:
  478. Value: !Ref webnet2
  479. DBnet1id:
  480. Value: !Ref dbnet1
  481. DBnet2id:
  482. Value: !Ref dbnet2
  483. Vpcid:
  484. Value: !Ref vpc1
  485. ELBsg:
  486. Value: !Ref elbgroup
  487. ServerSG:
  488. Value: !Ref webgroup
  489. MemSg:
  490. Value: !Ref dbgroup
  491. EFSsg:
  492. Value: !Ref efssg
  493. RedisSg:
  494. Value: !Ref redissg