-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2InstanceWithUserData.json
More file actions
86 lines (81 loc) · 3.01 KB
/
Copy pathec2InstanceWithUserData.json
File metadata and controls
86 lines (81 loc) · 3.01 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
"Parameters" : {
"InstanceType" : {
"Description" : "WebServer EC2 instance type",
"Type" : "String",
"Default" : "t2.micro",
"AllowedValues" : [ "t1.micro", "t2.nano", "t2.micro", "t2.small", "t2.medium", "t2.large", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "g2.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"],
"ConstraintDescription" : "must be a valid EC2 instance type."
},
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
}
},
"Mappings" : {
"RegionMap" : {
"us-east-1" : { "AMI" : "ami-1853ac65" },
"us-west-1" : { "AMI" : "ami-bf5540df" },
"eu-west-1" : { "AMI" : "ami-3bfab942" },
"ap-southeast-1" : { "AMI" : "ami-e2adf99e" },
"ap-southeast-2" : { "AMI" : "ami-43874721" }
}
},
"Resources" : {
"ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI"]},
"InstanceType" : {"Ref" : "InstanceType"},
"Tags" : [
{
"Key" : "Name",
"Value" : { "Fn::Join" : [ ":", [ "Ec2", "Instance", "created on ", { "Ref" : "AWS::Region" } ] ] }
}
],
"SecurityGroups": [
{ "Ref" : "MySecurityGroup" }
],
"KeyName" : {"Ref" : "KeyName"},
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -xe\n",
"yum update -y\n",
"yum install -y httpd\n",
"echo 'Its working...' > /var/www/html/index.html \n",
"service httpd start"
]]}}
}
},
"MySecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Enable SSH access via port 22",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol" : "tcp",
"FromPort" : "80",
"ToPort" : "80",
"CidrIp" : "0.0.0.0/0"
}
]
}
},
},
"Outputs": {
"ServerDns": {
"Value": {
"Fn::GetAtt":[
"ec2Instance",
"PublicIp"
]
}
}
}
}