forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
48 lines (42 loc) · 1.05 KB
/
__main__.py
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
import pulumi
from pulumi_gcp import compute
script = "#!/bin/bash\nsudo touch /tmp/a.txt\nsudo yum install -y nginx\nsudo service nginx start"
addr = compute.address.Address("poc")
network = compute.Network("poc")
firewall = compute.Firewall(
"poc",
network=network.self_link,
allows=[
{
"protocol": "tcp",
"ports": ["22"]
},
{
"protocol": "tcp",
"ports": ["80"]
}
]
)
instance = compute.Instance(
"poc",
name="poc",
machine_type="f1-micro",
boot_disk={
"initializeParams": {
"image": "centos-cloud/centos-7-v20190116"
}
},
network_interfaces=[
{
"network": network.id,
"accessConfigs": [{
"nat_ip": addr.address
}]
}
],
metadata_startup_script=script,
)
# Export the DNS name of the bucket
pulumi.export("instance_name", instance.name)
pulumi.export("instance_network", instance.network_interfaces)
pulumi.export("external_ip", addr.address)