-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
webserver-json.pp
55 lines (48 loc) 路 1.01 KB
/
webserver-json.pp
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
config instanceType string {
default = "t3.micro"
}
resource webSecGrp "aws:ec2/securityGroup:SecurityGroup" {
__logicalName = "WebSecGrp"
ingress = [{
protocol = "tcp",
fromPort = 80,
toPort = 80,
cidrBlocks = ["0.0.0.0/0"]
}]
options {
version = "4.37.1"
}
}
resource webServer "aws:ec2/instance:Instance" {
__logicalName = "WebServer"
instanceType = instanceType
ami = invoke("aws:index/getAmi:getAmi", {
filters = [{
name = "name",
values = ["amzn-ami-hvm-*-x86_64-ebs"]
}],
owners = ["137112412989"],
mostRecent = true
}).id
userData = join("\n", [
"#!/bin/bash",
"echo 'Hello, World from ${webSecGrp.arn}!' > index.html",
"nohup python -m SimpleHTTPServer 80 &"
])
vpcSecurityGroupIds = [webSecGrp.id]
options {
version = "4.37.1"
}
}
output instanceId {
__logicalName = "InstanceId"
value = webServer.id
}
output publicIp {
__logicalName = "PublicIp"
value = webServer.publicIp
}
output publicHostName {
__logicalName = "PublicHostName"
value = webServer.publicDns
}