-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2CloudFormationYaml
52 lines (52 loc) · 1.84 KB
/
ec2CloudFormationYaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
AWSTemplateFormatVersion: 2010-09-09
Parameters:
SubnetID:
Type: AWS::EC2::Subnet::Id
Description: Subnet to deploy EC2 instance into
SecurityGroupIDs:
Type: List<AWS::EC2::SecurityGroup::Id>
Description: List of Security Groups to add to EC2 instance
KeyName:
Type: AWS::EC2::KeyPair::KeyName
Description: >-
Name of an existing EC2 KeyPair to enable SSH access to the instance
InstanceType:
Description: EC2 instance type
Type: String
Default: t2.micro
Mappings:
AWSRegionToAMI:
us-east-1:
AMIID: ami-0b33d91d
us-east-2:
AMIID: ami-c55673a0
Resources:
EC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId:
!FindInMap # This is an example of the short form YAML FindInMap function
- AWSRegionToAMI # It accepts three parameters each denoted by a hyphen (-)
- !Ref AWS::Region
- AMIID
InstanceType: !Ref InstanceType
KeyName: !Ref KeyName
SecurityGroupIds: !Ref SecurityGroupIDs
SubnetId: !Ref SubnetID
UserData:
Fn::Base64: # YAML makes userdata much cleaner
!Sub |
#!/bin/bash -ex
yum install -y httpd;
echo "<html>I love YAML CloudFormation!!</html>" > /var/www/html/index.html;
cd /var/www/html;
chmod 755 index.html;
service httpd start;
chkconfig httpd on;
Tags: # Tags are an example of a sequence of mappings in YAML,
- # each key/value pair is separated by a hyphen
Key: Name
Value: CloudFormation Test - YAML
-
Key: Environment
Value: Development