This repository has been archived by the owner on Oct 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 209
/
demo.json
84 lines (84 loc) · 2.32 KB
/
demo.json
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
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Hello World! example",
"Parameters": {
"VPC": {
"Description": "The default VPC",
"Type": "AWS::EC2::VPC::Id"
},
"Subnet": {
"Description": "A public subnet from default VPC.",
"Type": "AWS::EC2::Subnet::Id"
},
"SubnetType": {
"Description": "Choose the type of the subnet.",
"Type": "String",
"AllowedValues": [
"Private",
"Public"
]
}
},
"Conditions": {
"HasPublicSubnet": {"Fn::Equals": [{"Ref": "SubnetType"}, "Public"]}
},
"Mappings": {
"RegionMap": {
"eu-west-1": {"AMI": "ami-bff32ccc"},
"ap-southeast-1": {"AMI": "ami-c9b572aa"},
"ap-southeast-2": {"AMI": "ami-48d38c2b"},
"eu-central-1": {"AMI": "ami-bc5b48d0"},
"ap-northeast-2": {"AMI": "ami-249b554a"},
"ap-northeast-1": {"AMI": "ami-383c1956"},
"us-east-1": {"AMI": "ami-60b6c60a"},
"sa-east-1": {"AMI": "ami-6817af04"},
"us-west-1": {"AMI": "ami-d5ea86b5"},
"us-west-2": {"AMI": "ami-f0091d91"}
}
},
"Resources": {
"EC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {"Fn::FindInMap": ["RegionMap", {"Ref": "AWS::Region"}, "AMI"]},
"InstanceType": "t2.micro",
"NetworkInterfaces": [{
"AssociatePublicIpAddress": {"Fn::If" : ["HasPublicSubnet", "true", "false"]},
"DeviceIndex": "0",
"GroupSet": [{"Ref": "WebserverSecurityGroup"}],
"SubnetId": {"Ref": "Subnet"}
}],
"Tags": [{
"Key": "Name",
"Value": "hello-world"
}],
"UserData": {"Fn::Base64": {"Fn::Join": ["", [
"#!/bin/bash -ex\n",
"yum install -y httpd\n",
"cd /var/www/html\n",
"echo '<html><body>Hello World!</body></html>' > index.html\n",
"service httpd start\n"
]]}}
}
},
"WebserverSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "hello-world-webserver",
"VpcId": {"Ref": "VPC"},
"SecurityGroupIngress": [{
"CidrIp": "0.0.0.0/0",
"FromPort": 80,
"IpProtocol": "tcp",
"ToPort": 80
}]
}
}
},
"Outputs": {
"HelloWorldURL": {
"Description": "The URL pointing to Hello World!.",
"Value": {"Fn::If" : ["HasPublicSubnet", {"Fn::Join": ["", ["http://", {"Fn::GetAtt": ["EC2Instance", "PublicIp"]}]]}, {"Fn::Join": ["", ["http://", {"Fn::GetAtt": ["EC2Instance", "PrivateIp"]}]]}]}
}
}
}