-
Notifications
You must be signed in to change notification settings - Fork 880
/
index.js
39 lines (34 loc) · 1.17 KB
/
index.js
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
const gcp = require("@pulumi/gcp");
const computeNetwork = new gcp.compute.Network("network", {
autoCreateSubnetworks: true,
});
const computeFirewall = new gcp.compute.Firewall("firewall", {
network: computeNetwork.selfLink,
allows: [{
protocol: "tcp",
ports: [ "22", "80" ],
}],
sourceTags: ["web"],
});
// (optional) create a simple web server using the startup script for the instance
const startupScript = `#!/bin/bash
echo "Hello, World!" > index.html
nohup python -m SimpleHTTPServer 80 &`;
const computeInstance = new gcp.compute.Instance("instance", {
machineType: "f1-micro",
metadataStartupScript: startupScript,
bootDisk: {
initializeParams: {
image: "debian-cloud/debian-9-stretch-v20181210",
},
},
networkInterfaces: [{
network: computeNetwork.id,
accessConfigs: [{}], // must be empty to request an ephemeral IP
}],
serviceAccount: {
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
},
}, { dependsOn: [computeFirewall] });
exports.instanceName = computeInstance.name;
exports.instanceIP = computeInstance.networkInterfaces[0].accessConfigs[0].natIp;