Add a GCP webserver example
Fixes
ADD
gcp-js-webserver/Pulumi.yaml
+name: webserver-gcp
+runtime: nodejs
+description: Basic example of an Google Cloud web server accessible over HTTP.

ADD
gcp-js-webserver/index.js
+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" ],
+ }],
+});
+
+// (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-8",
+ },
+ },
+ 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.apply(ni => ni[0].accessConfigs[0].natIp);

ADD
gcp-js-webserver/package.json
+{
+ "name": "webserver-gcp",
+ "version": "0.1.0",
+ "main": "index.js",
+ "dependencies": {
+ "@pulumi/pulumi": "^0.14.0",
+ "@pulumi/gcp": "^0.14.0"
+ }
+}

Add a GCP webserver example (#100)

Fixes #90.