Guest User

Untitled

a guest
Jul 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.93 KB | None | 0 0
  1. Metadata:
  2. License: Apache-2.0
  3. AWSTemplateFormatVersion: '2010-09-09'
  4. Description: 'AWS CloudFormation Sample Template Sample template EIP_With_Association:
  5. This template shows how to associate an Elastic IP address with an Amazon EC2 instance
  6. - you can use this same technique to associate an EC2 instance with an Elastic IP
  7. Address that is not created inside the template by replacing the EIP reference in
  8. the AWS::EC2::EIPAssoication resource type with the IP address of the external EIP.
  9. **WARNING** This template creates an Amazon EC2 instance and an Elastic IP Address.
  10. You will be billed for the AWS resources used if you create a stack from this template.'
  11. Parameters:
  12. InstanceType:
  13. Description: WebServer EC2 instance type
  14. Type: String
  15. Default: t2.small
  16. AllowedValues: [t1.micro, t2.nano, t2.micro, t2.small, t2.medium, t2.large, m1.small,
  17. m1.medium, m1.large, m1.xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, m3.medium,
  18. m3.large, m3.xlarge, m3.2xlarge, m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge,
  19. m4.10xlarge, c1.medium, c1.xlarge, c3.large, c3.xlarge, c3.2xlarge, c3.4xlarge,
  20. c3.8xlarge, c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge, g2.2xlarge,
  21. g2.8xlarge, r3.large, r3.xlarge, r3.2xlarge, r3.4xlarge, r3.8xlarge, i2.xlarge,
  22. i2.2xlarge, i2.4xlarge, i2.8xlarge, d2.xlarge, d2.2xlarge, d2.4xlarge, d2.8xlarge,
  23. hi1.4xlarge, hs1.8xlarge, cr1.8xlarge, cc2.8xlarge, cg1.4xlarge]
  24. ConstraintDescription: must be a valid EC2 instance type.
  25. KeyName:
  26. Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
  27. Type: AWS::EC2::KeyPair::KeyName
  28. ConstraintDescription: must be the name of an existing EC2 KeyPair.
  29. SSHLocation:
  30. Description: The IP address range that can be used to SSH to the EC2 instances
  31. Type: String
  32. MinLength: '9'
  33. MaxLength: '18'
  34. Default: 0.0.0.0/0
  35. AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
  36. ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
  37. Mappings:
  38. AWSInstanceType2Arch:
  39. t1.micro:
  40. Arch: PV64
  41. t2.nano:
  42. Arch: HVM64
  43. t2.micro:
  44. Arch: HVM64
  45. t2.small:
  46. Arch: HVM64
  47. t2.medium:
  48. Arch: HVM64
  49. t2.large:
  50. Arch: HVM64
  51. m1.small:
  52. Arch: PV64
  53. m1.medium:
  54. Arch: PV64
  55. m1.large:
  56. Arch: PV64
  57. m1.xlarge:
  58. Arch: PV64
  59. m2.xlarge:
  60. Arch: PV64
  61. m2.2xlarge:
  62. Arch: PV64
  63. m2.4xlarge:
  64. Arch: PV64
  65. m3.medium:
  66. Arch: HVM64
  67. m3.large:
  68. Arch: HVM64
  69. m3.xlarge:
  70. Arch: HVM64
  71. m3.2xlarge:
  72. Arch: HVM64
  73. m4.large:
  74. Arch: HVM64
  75. m4.xlarge:
  76. Arch: HVM64
  77. m4.2xlarge:
  78. Arch: HVM64
  79. m4.4xlarge:
  80. Arch: HVM64
  81. m4.10xlarge:
  82. Arch: HVM64
  83. c1.medium:
  84. Arch: PV64
  85. c1.xlarge:
  86. Arch: PV64
  87. c3.large:
  88. Arch: HVM64
  89. c3.xlarge:
  90. Arch: HVM64
  91. c3.2xlarge:
  92. Arch: HVM64
  93. c3.4xlarge:
  94. Arch: HVM64
  95. c3.8xlarge:
  96. Arch: HVM64
  97. c4.large:
  98. Arch: HVM64
  99. c4.xlarge:
  100. Arch: HVM64
  101. c4.2xlarge:
  102. Arch: HVM64
  103. c4.4xlarge:
  104. Arch: HVM64
  105. c4.8xlarge:
  106. Arch: HVM64
  107. g2.2xlarge:
  108. Arch: HVMG2
  109. g2.8xlarge:
  110. Arch: HVMG2
  111. r3.large:
  112. Arch: HVM64
  113. r3.xlarge:
  114. Arch: HVM64
  115. r3.2xlarge:
  116. Arch: HVM64
  117. r3.4xlarge:
  118. Arch: HVM64
  119. r3.8xlarge:
  120. Arch: HVM64
  121. i2.xlarge:
  122. Arch: HVM64
  123. i2.2xlarge:
  124. Arch: HVM64
  125. i2.4xlarge:
  126. Arch: HVM64
  127. i2.8xlarge:
  128. Arch: HVM64
  129. d2.xlarge:
  130. Arch: HVM64
  131. d2.2xlarge:
  132. Arch: HVM64
  133. d2.4xlarge:
  134. Arch: HVM64
  135. d2.8xlarge:
  136. Arch: HVM64
  137. hi1.4xlarge:
  138. Arch: HVM64
  139. hs1.8xlarge:
  140. Arch: HVM64
  141. cr1.8xlarge:
  142. Arch: HVM64
  143. cc2.8xlarge:
  144. Arch: HVM64
  145. AWSInstanceType2NATArch:
  146. t1.micro:
  147. Arch: NATPV64
  148. t2.nano:
  149. Arch: NATHVM64
  150. t2.micro:
  151. Arch: NATHVM64
  152. t2.small:
  153. Arch: NATHVM64
  154. t2.medium:
  155. Arch: NATHVM64
  156. t2.large:
  157. Arch: NATHVM64
  158. m1.small:
  159. Arch: NATPV64
  160. m1.medium:
  161. Arch: NATPV64
  162. m1.large:
  163. Arch: NATPV64
  164. m1.xlarge:
  165. Arch: NATPV64
  166. m2.xlarge:
  167. Arch: NATPV64
  168. m2.2xlarge:
  169. Arch: NATPV64
  170. m2.4xlarge:
  171. Arch: NATPV64
  172. m3.medium:
  173. Arch: NATHVM64
  174. m3.large:
  175. Arch: NATHVM64
  176. m3.xlarge:
  177. Arch: NATHVM64
  178. m3.2xlarge:
  179. Arch: NATHVM64
  180. m4.large:
  181. Arch: NATHVM64
  182. m4.xlarge:
  183. Arch: NATHVM64
  184. m4.2xlarge:
  185. Arch: NATHVM64
  186. m4.4xlarge:
  187. Arch: NATHVM64
  188. m4.10xlarge:
  189. Arch: NATHVM64
  190. c1.medium:
  191. Arch: NATPV64
  192. c1.xlarge:
  193. Arch: NATPV64
  194. c3.large:
  195. Arch: NATHVM64
  196. c3.xlarge:
  197. Arch: NATHVM64
  198. c3.2xlarge:
  199. Arch: NATHVM64
  200. c3.4xlarge:
  201. Arch: NATHVM64
  202. c3.8xlarge:
  203. Arch: NATHVM64
  204. c4.large:
  205. Arch: NATHVM64
  206. c4.xlarge:
  207. Arch: NATHVM64
  208. c4.2xlarge:
  209. Arch: NATHVM64
  210. c4.4xlarge:
  211. Arch: NATHVM64
  212. c4.8xlarge:
  213. Arch: NATHVM64
  214. g2.2xlarge:
  215. Arch: NATHVMG2
  216. g2.8xlarge:
  217. Arch: NATHVMG2
  218. r3.large:
  219. Arch: NATHVM64
  220. r3.xlarge:
  221. Arch: NATHVM64
  222. r3.2xlarge:
  223. Arch: NATHVM64
  224. r3.4xlarge:
  225. Arch: NATHVM64
  226. r3.8xlarge:
  227. Arch: NATHVM64
  228. i2.xlarge:
  229. Arch: NATHVM64
  230. i2.2xlarge:
  231. Arch: NATHVM64
  232. i2.4xlarge:
  233. Arch: NATHVM64
  234. i2.8xlarge:
  235. Arch: NATHVM64
  236. d2.xlarge:
  237. Arch: NATHVM64
  238. d2.2xlarge:
  239. Arch: NATHVM64
  240. d2.4xlarge:
  241. Arch: NATHVM64
  242. d2.8xlarge:
  243. Arch: NATHVM64
  244. hi1.4xlarge:
  245. Arch: NATHVM64
  246. hs1.8xlarge:
  247. Arch: NATHVM64
  248. cr1.8xlarge:
  249. Arch: NATHVM64
  250. cc2.8xlarge:
  251. Arch: NATHVM64
  252. AWSRegionArch2AMI:
  253. us-east-1:
  254. PV64: ami-2a69aa47
  255. HVM64: ami-6869aa05
  256. HVMG2: ami-50b4f047
  257. us-west-2:
  258. PV64: ami-7f77b31f
  259. HVM64: ami-7172b611
  260. HVMG2: ami-002bf460
  261. us-west-1:
  262. PV64: ami-a2490dc2
  263. HVM64: ami-31490d51
  264. HVMG2: ami-699ad409
  265. eu-west-1:
  266. PV64: ami-4cdd453f
  267. HVM64: ami-f9dd458a
  268. HVMG2: ami-f0e0a483
  269. eu-central-1:
  270. PV64: ami-6527cf0a
  271. HVM64: ami-ea26ce85
  272. HVMG2: ami-d9d62ab6
  273. ap-northeast-1:
  274. PV64: ami-3e42b65f
  275. HVM64: ami-374db956
  276. HVMG2: ami-78ba6619
  277. ap-northeast-2:
  278. PV64: NOT_SUPPORTED
  279. HVM64: ami-2b408b45
  280. HVMG2: NOT_SUPPORTED
  281. ap-southeast-1:
  282. PV64: ami-df9e4cbc
  283. HVM64: ami-a59b49c6
  284. HVMG2: ami-56e84c35
  285. ap-southeast-2:
  286. PV64: ami-63351d00
  287. HVM64: ami-dc361ebf
  288. HVMG2: ami-2589b946
  289. ap-south-1:
  290. PV64: NOT_SUPPORTED
  291. HVM64: ami-ffbdd790
  292. HVMG2: ami-f7354198
  293. us-east-2:
  294. PV64: NOT_SUPPORTED
  295. HVM64: ami-f6035893
  296. HVMG2: NOT_SUPPORTED
  297. sa-east-1:
  298. PV64: ami-1ad34676
  299. HVM64: ami-6dd04501
  300. HVMG2: NOT_SUPPORTED
  301. cn-north-1:
  302. PV64: ami-77559f1a
  303. HVM64: ami-8e6aa0e3
  304. HVMG2: NOT_SUPPORTED
  305. Resources:
  306. EC2Instance:
  307. Type: AWS::EC2::Instance
  308. Properties:
  309. UserData: !Base64
  310. Fn::Join:
  311. - ''
  312. - [IPAddress=, !Ref 'IPAddress']
  313. InstanceType: !Ref 'InstanceType'
  314. SecurityGroups: [!Ref 'InstanceSecurityGroup']
  315. KeyName: !Ref 'KeyName'
  316. ImageId: !FindInMap [AWSRegionArch2AMI, !Ref 'AWS::Region', !FindInMap [AWSInstanceType2Arch,
  317. !Ref 'InstanceType', Arch]]
  318. InstanceSecurityGroup:
  319. Type: AWS::EC2::SecurityGroup
  320. Properties:
  321. GroupDescription: Enable SSH access
  322. SecurityGroupIngress:
  323. - IpProtocol: tcp
  324. FromPort: '22'
  325. ToPort: '22'
  326. CidrIp: !Ref 'SSHLocation'
  327. IPAddress:
  328. Type: AWS::EC2::EIP
  329. IPAssoc:
  330. Type: AWS::EC2::EIPAssociation
  331. Properties:
  332. InstanceId: !Ref 'EC2Instance'
  333. EIP: !Ref 'IPAddress'
  334. Outputs:
  335. InstanceId:
  336. Description: InstanceId of the newly created EC2 instance
  337. Value: !Ref 'EC2Instance'
  338. InstanceIPAddress:
  339. Description: IP address of the newly created EC2 instance
  340. Value: !Ref 'IPAddress'
Add Comment
Please, Sign In to add comment