Update to 0.10 packages for examples
MODIFY
README.md
README.md
# Pulumi Examples
-- [URL shortener](/url-shortener)
-- [Web Server](/webserver)
\ No newline at end of file
+- [URL shortener](url-shortener/)
+- [URL shortener with cache](url-shortener-with-cache/)
+- [Web server](webserver/)
+- [Web server with a function](webserver-component/)
+- [Web server in multiple availability zones](webserver-zones/)

MODIFY
url-shortener-with-cache/package.json
url-shortener-with-cache/package.json
"@types/node": "^8.0.27",
"typescript": "^2.1.4"
},
- "peerDependencies": {
- "@pulumi/cloud": "*"
- },
"dependencies": {
- "redis": "^2.8.0"
+ "redis": "^2.8.0",
+ "@pulumi/cloud": "^0.10.0",
+ "@pulumi/cloud-aws": "^0.10.0"
}
}

MODIFY
voting-app/.gitignore
voting-app/.gitignore
/bin/
/node_modules/
/yarn.lock
+/package-lock.json

MODIFY
voting-app/package.json
voting-app/package.json
{
"name": "pulumi-voting-app",
- "version": "0.1",
+ "version": "0.1.0",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"@types/node": "^8.0.27",
"typescript": "^2.1.4"
},
- "peerDependencies": {
- "@pulumi/cloud": "*"
+ "dependencies": {
+ "@pulumi/cloud": "^0.10.0",
+ "@pulumi/cloud-aws": "^0.10.0"
}
}

MODIFY
webserver-component/.gitignore
webserver-component/.gitignore
/bin/
/node_modules/
/yarn.lock
+/package-lock.json

MODIFY
webserver-component/index.ts
webserver-component/index.ts
import * as aws from "@pulumi/aws";
import * as webserver from "./webserver"; // use the new custom component
+import { Output } from "@pulumi/pulumi"; // for output property
-let webInstance = webserver.createInstance("web-server-www", "t2.micro");
-let appInstance = webserver.createInstance("web-server-app", "t2.nano");
\ No newline at end of file
+let webInstance = webserver.createInstance("web-server-www", "t2.nano");
+let appInstance = webserver.createInstance("web-server-app", "t2.micro");
+
+export let webUrl = webInstance.publicDns.apply(dns => `http://${dns}`);

MODIFY
webserver-component/package.json
webserver-component/package.json
{
"name": "webserver",
- "version": "0.1",
+ "version": "0.1.0",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
- "typescript": "^2.5.3"
- },
- "peerDependencies": {
- "@pulumi/aws": "*",
- "pulumi": "*"
+ "typescript": "^2.5.3",
+ "@types/node": "^8.0.26"
},
"dependencies": {
- "@types/node": "^8.0.26"
+ "@pulumi/pulumi": "^0.10.0",
+ "@pulumi/aws": "^0.10.0"
}
}

MODIFY
webserver-component/tsconfig.json
webserver-component/tsconfig.json
"strictNullChecks": true
},
"files": [
- "index.ts"
+ "index.ts",
+ "webserver.ts"
]
}

MODIFY
webserver-component/webserver.ts
webserver-component/webserver.ts
@@ -25,7 +25,5 @@ export function createInstance(name: string, size: aws.ec2.InstanceType): aws.ec
userData: userData // set up a simple web server
});
- result.publicDns.then(url => console.log(`Server URL: http://${url}`));
-
return result;
}
\ No newline at end of file

MODIFY
webserver-zones/.gitignore
webserver-zones/.gitignore
/bin/
/node_modules/
/yarn.lock
+/package-lock.json

MODIFY
webserver-zones/index.ts
webserver-zones/index.ts
import * as aws from "@pulumi/aws";
import * as webserver from "./webserver"; // use the new custom component
+import * as pulumi from "@pulumi/pulumi";
-// the async block is currently required, due to the use of `await`
-// this will be improved in the future
-(async () => {
+// the async block is required since `getAvailabilityZones` returns a promise
+export let serverUrls = (async () => {
let zones: string[] = (await aws.getAvailabilityZones()).names;
+ let urls: pulumi.Output<string>[] = []; // save the URL of each created instance
+
for (let i = 0; i < zones.length; i++) {
let server = webserver.createInstance(`web-server-www-${i}`, "t2.micro", zones[i]);
+ urls.push(server.publicDns.apply(dns => `http://${dns}`));
}
+
+ return urls;
})();
+

MODIFY
webserver-zones/package.json
webserver-zones/package.json
{
"name": "webserver",
- "version": "0.1",
+ "version": "0.1.0",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
- "typescript": "^2.5.3"
- },
- "peerDependencies": {
- "@pulumi/aws": "*",
- "pulumi": "*"
+ "typescript": "^2.5.3",
+ "@types/node": "^8.0.26"
},
"dependencies": {
- "@types/node": "^8.0.26"
+ "@pulumi/pulumi": "^0.10.0",
+ "@pulumi/aws": "^0.10.0"
}
}

MODIFY
webserver-zones/tsconfig.json
webserver-zones/tsconfig.json
"strictNullChecks": true
},
"files": [
- "index.ts"
+ "index.ts",
+ "webserver.ts"
]
}

MODIFY
webserver-zones/webserver.ts
webserver-zones/webserver.ts
@@ -19,14 +19,12 @@ let userData =
export function createInstance(name: string, size: aws.ec2.InstanceType, zone: string): aws.ec2.Instance {
let result = new aws.ec2.Instance(name, {
availabilityZone: zone,
- tags: { "Name": name },
+ tags: { "Name": name }, // use the `name` parameter
instanceType: size, // use function argument for size
securityGroups: [ group.name ], // reference the group object above
ami: aws.ec2.getLinuxAMI(size), // call built-in function (can also be custom)
userData: userData // set up a simple web server
});
- result.publicDns.then(url => console.log(`Server URL: http://${url}`));
-
return result;
}
\ No newline at end of file

MODIFY
webserver/.gitignore
webserver/.gitignore
/bin/
/node_modules/
/yarn.lock
+/package-lock.json

Update to 0.10 packages for examples (#16)