-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudformation-ec2-instance.json
More file actions
87 lines (82 loc) · 2.3 KB
/
Copy pathcloudformation-ec2-instance.json
File metadata and controls
87 lines (82 loc) · 2.3 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
86
87
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "create ec2 instance with security group",
"Parameters": {
"sgName":{
"Description": "ec2-security-group",
"Type":"String",
"Default":"mysg"
},
"VpcId":{
"Description": "Vpc id",
"Type":"AWS::EC2::VPC::Id",
"Default":"-"
},
"keypair":{
"Description":"-",
"Type":"AWS::EC2::KeyPair::KeyName",
"Default":"-"
}
},
"Resources": {
"secGroupName" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "-",
"SecurityGroupIngress" : [
{
"IpProtocol": "tcp",
"FromPort": 80,
"ToPort": 80,
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": 22,
"ToPort": 22,
"CidrIp": "0.0.0.0/0"
}
],
"VpcId" : {
"Ref":"VpcId"
},
"Tags" : [
{
"Key":"environment",
"Value":"dev"
}
]
}
},
"ec2instance": {
"Type": "AWS::EC2::Instance",
"DependsOn":["secGroupName"],
"Properties": {
"KeyName":
{"Ref": "keypair"},
"ImageId": "ami-019715e0d74f695be",
"InstanceType": "t3.micro",
"Monitoring": "false",
"SecurityGroupIds" : [
{"Ref":"secGroupName"}
],
"Tags": [
{
"Key": "environment",
"Value": "dev"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash -ex",
"sudo apt get update && sudo apt-get install apache2 -y"
]
]
}
}
} }
}
}