Skip to content

Commit

Permalink
Update examples for v0.15 (pulumi#120)
Browse files Browse the repository at this point in the history
- Update dependencies to 0.15.0 and 0.15.1 as appropriate
- Use first-class TypeScript support for TypeScript examples
- `pulumi update` => `pulumi up`
- Fixed the aws-js-s3-folder-component example
  • Loading branch information
justinvp committed Aug 20, 2018
1 parent 8d9b0ac commit f533be1
Show file tree
Hide file tree
Showing 65 changed files with 135 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.2.1
- export PATH=$HOME/.yarn/bin:$PATH
# Install Pulumi
- curl -L https://get.pulumi.com/ | bash -s -- --version 0.14.2
- curl -L https://get.pulumi.com/ | bash -s -- --version 0.15.0
- export PATH=$HOME/.pulumi/bin:$PATH
install:
# Now restore all dependencies, after cloning, to rebuild vendor appropriately.
Expand Down
4 changes: 2 additions & 2 deletions aws-go-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ For a detailed walkthrough of this example, see the tutorial [Static Website on
$ go install .
```

4. Run `pulumi update` to preview and deploy changes.
4. Run `pulumi up` to preview and deploy changes.

```bash
$ pulumi update
$ pulumi up
Previewing stack 'website-testing'
Previewing changes:
...
Expand Down
4 changes: 2 additions & 2 deletions aws-js-s3-folder-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ with `***`.

1. Restore NPM modules via `npm install` or `yarn install`.

1. Run `pulumi update` to preview and deploy changes. After the preview is shown you will be
1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
prompted if you want to continue or not.

```bash
$ pulumi update
$ pulumi up
Previewing update of stack 'website-component-testing'
Previewing changes:
...
Expand Down
2 changes: 1 addition & 1 deletion aws-js-s3-folder-component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ let folder = new s3folder.S3Folder("pulumi-static-site", "./www");

// Export `folder` output properties as stack outputs
exports.bucketName = folder.bucketName;
exports.websiteUrl = folder.websiteUrl;
exports.websiteUrl = folder.websiteUrl;
4 changes: 2 additions & 2 deletions aws-js-s3-folder-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "aws-js-s3-folder-component",
"main": "index.js",
"dependencies": {
"@pulumi/aws": "^0.14.0",
"@pulumi/pulumi": "^0.14.0",
"@pulumi/aws": "^0.15.0",
"@pulumi/pulumi": "^0.15.0",
"mime": "^2.2.2"
}
}
18 changes: 9 additions & 9 deletions aws-js-s3-folder-component/s3folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ const mime = require("mime");
class S3Folder extends pulumi.ComponentResource {

constructor(bucketName, path, opts) {
super("examples:S3Folder", bucketName, {}, opts); // Register this component with name examples:S3Folder
super("pulumi:examples:S3Folder", bucketName, {}, opts); // Register this component with name pulumi:examples:S3Folder

// Create a bucket and expose a website index document
let siteBucket = new aws.s3.Bucket(bucketName, {
websites: [{
website: {
indexDocument: "index.html",
}],
},
}, { parent: this }); // specify resource parent

// For each file in the directory, create an S3 object stored in `siteBucket`
for (let item of require("fs").readdirSync(path)) {
let filePath = require("path").join(path, item);
let object = new aws.s3.BucketObject(item, {
let object = new aws.s3.BucketObject(item, {
bucket: siteBucket, // reference the s3.Bucket object
source: new pulumi.asset.FileAsset(filePath), // use FileAsset to point to a file
contentType: mime.getType(filePath) || undefined, // set the MIME type of the file
}, { parent: this }); // specify resource parent
}

// Set the access policy for the bucket so all objects are readable
let bucketPolicy = new aws.s3.BucketPolicy("bucketPolicy", {
bucket: siteBucket.bucket,
policy: siteBucket.bucket.apply(this.publicReadPolicyForBucket),
}, { parent: this }); // specify resource parent

this.bucketName = siteBucket.bucket,
this.websiteUrl = siteBucket.websiteEndpoint,
this.bucketName = siteBucket.bucket;
this.websiteUrl = siteBucket.websiteEndpoint;

// Register output properties for this component
this.registerOutputs({
bucketName: this.bucketName,
websiteUrl: this.websiteEndpoint,
websiteUrl: this.websiteUrl,
});
}

Expand All @@ -57,7 +57,7 @@ class S3Folder extends pulumi.ComponentResource {
]
}]
});
}
}
}

module.exports.S3Folder = S3Folder;
4 changes: 2 additions & 2 deletions aws-js-s3-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ with `***`.

1. Restore NPM modules via `npm install` or `yarn install`.

1. Run `pulumi update` to preview and deploy changes. After the preview is shown you will be
1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
prompted if you want to continue or not.

```bash
$ pulumi update
$ pulumi up
Previewing update of stack 'website-testing'
Previewing changes:
...
Expand Down
4 changes: 2 additions & 2 deletions aws-js-s3-folder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "aws-js-s3-folder",
"main": "index.js",
"dependencies": {
"@pulumi/aws": "^0.14.0",
"@pulumi/pulumi": "^0.14.0",
"@pulumi/aws": "^0.15.0",
"@pulumi/pulumi": "^0.15.0",
"mime": "^2.2.2"
}
}
6 changes: 3 additions & 3 deletions aws-js-sqs-slack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ After installing the CLI and cloning the repo, `cd` into the directory, and run
$ pulumi config set slackToken xoxb-123456789012-Xw937qtWSXJss1lFaKeqFAKE --secret
```

4. Deploy your program to AWS using the `pulumi update` command:
4. Deploy your program to AWS using the `pulumi up` command:

```
$ pulumi update
$ pulumi up
```

This command will show you the changes before it makes them. As soon as you select `yes`, it will begin
Expand All @@ -66,7 +66,7 @@ After installing the CLI and cloning the repo, `cd` into the directory, and run
2018-07-05T16:46:03.708-07:00[mySlackPoster-queue-subscripti] 2018-07-05T23:46:03.708Z 68b50931-a005-5e85-b5c4-5a890fee5519 Posted SQS message 3caa4069-f549-44d7-8534-6d61840d3420 to Slack channel #general
```

7. If you'd like to make some edits, try changing the `index.js` file, and then just run `pulumi update` again.
7. If you'd like to make some edits, try changing the `index.js` file, and then just run `pulumi up` again.
Pulumi will detect the minimal set of edits needed to deploy your code.

8. After you're done playing around, you can destroy your program and stack by simply running two commands:
Expand Down
4 changes: 2 additions & 2 deletions aws-js-webserver-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"main": "index.js",
"dependencies": {
"@pulumi/pulumi": "^0.14.0",
"@pulumi/aws": "^0.14.0"
"@pulumi/pulumi": "^0.15.0",
"@pulumi/aws": "^0.15.0"
}
}
4 changes: 2 additions & 2 deletions aws-js-webserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"main": "index.js",
"dependencies": {
"@pulumi/pulumi": "^0.14.0",
"@pulumi/aws": "^0.14.0"
"@pulumi/pulumi": "^0.15.0",
"@pulumi/aws": "^0.15.0"
}
}
2 changes: 1 addition & 1 deletion aws-py-stepfunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $ pulumi stack init stepfunctions-dev
$ pulumi config set aws:region us-east-2
# Preview and run the deployment
$ pulumi update
$ pulumi up
# Start execution using the AWS CLI (or from the console at https://console.aws.amazon.com/states)
$ aws stepfunctions start-execution --state-machine-arn $(pulumi stack output state_machine_arn)
Expand Down
4 changes: 2 additions & 2 deletions aws-py-stepfunctions/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulumi>=0.14.0
pulumi-aws>=0.14.3
pulumi>=0.15.0
pulumi-aws>=0.15.0
4 changes: 2 additions & 2 deletions aws-py-webserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ To get the correct Amazon Linux AMI for the instance size and region, a mapping
$ pulumi config set aws:region us-west-2
```

1. Run `pulumi update` to preview and deploy changes:
1. Run `pulumi up` to preview and deploy changes:

```
$ pulumi update
$ pulumi up
Previewing stack 'python-webserver-testing'
Previewing changes:
...
Expand Down
4 changes: 2 additions & 2 deletions aws-py-webserver/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pulumi>=0.14.0
pulumi-aws>=0.14.0
pulumi>=0.15.0
pulumi-aws>=0.15.0
3 changes: 1 addition & 2 deletions aws-ts-airflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ For more information on how to run this example, see: https://pulumi.io/referenc
```

1. Restore NPM modules via `yarn install`.
1. Build the TypeScript code via `yarn run build`.
1. Run `pulumi update` to preview and deploy changes. After the preview is shown you will be
1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be
prompted if you want to continue or not.

```
Expand Down
15 changes: 5 additions & 10 deletions aws-ts-airflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
"name": "airflow",
"version": "0.1",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"@types/node": "^10.1.2",
"typescript": "^2.8.3"
"@types/node": "^10.1.2"
},
"dependencies": {
"@pulumi/aws": "^0.14.0",
"@pulumi/cloud": "^0.14.0",
"@pulumi/cloud-aws": "^0.14.0",
"@pulumi/pulumi": "^0.14.0"
"@pulumi/aws": "^0.15.0",
"@pulumi/cloud": "^0.15.0",
"@pulumi/cloud-aws": "^0.15.0",
"@pulumi/pulumi": "^0.15.0"
}
}
1 change: 0 additions & 1 deletion aws-ts-eks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "aws-ts-eks",
"devDependencies": {
"typescript": "^2.7.2",
"@types/node": "latest"
},
"dependencies": {
Expand Down
6 changes: 2 additions & 4 deletions aws-ts-resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ $ pulumi config set aws:region us-east-2
# Install dependencies
$ npm install

# Compile the TypeScript program
npm run build

# Preview and run the deployment
$ pulumi update
$ pulumi up

# Remove the app
$ pulumi destroy
$ pulumi stack rm
```
6 changes: 0 additions & 6 deletions aws-ts-resources/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"name": "aws-ts-resources",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"typescript": "^2.7.2",
"@types/node": "latest"
},
"dependencies": {
Expand Down
12 changes: 2 additions & 10 deletions aws-ts-ruby-on-rails/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
"name": "aws-ec2-rails",
"version": "0.1.0",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"typescript": "^2.7.2"
},
"dependencies": {
"@pulumi/aws": "^0.14.0",
"@pulumi/pulumi": "^0.14.0",
"@pulumi/aws": "^0.15.0",
"@pulumi/pulumi": "^0.15.0",
"pawsami": "^0.1.1",
"pcloudinit": "^0.1.0"
}
Expand Down
8 changes: 1 addition & 7 deletions aws-ts-serverless-raw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ $ pulumi config set aws:region us-east-2
# Install dependencies
$ npm install

# Compile the TypeScript program
npm run build

# Build the C# app
$ cd ./app
$ dotnet publish
$ cd ..

# Build the Pulumi program
$ npm run build

# Preview and run the deployment
$ pulumi update
$ pulumi up
Previewing changes:
...
Performing changes:
Expand Down
12 changes: 2 additions & 10 deletions aws-ts-serverless-raw/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{
"name": "serverless-raw",
"version": "0.1.0",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"typescript": "^2.7.2"
},
"dependencies": {
"@pulumi/aws": "^0.14.0",
"@pulumi/pulumi": "^0.14.0"
"@pulumi/aws": "^0.15.0",
"@pulumi/pulumi": "^0.15.0"
}
}
7 changes: 3 additions & 4 deletions aws-ts-static-website/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ This sample uses the following AWS products:

## Getting Started

Install prerequisites and build the Pulumi program with:
Install prerequisites with:

```bash
npm install
npm run build
```

Configure the Pulumi program. There are several configuration settings that need to be
Expand All @@ -33,7 +32,7 @@ set:

The Pulumi program constructs the S3 bucket, and constructs an `aws.s3.BucketObject` object
for every file in `config.pathToWebsiteContents`. This is essentially tracks every file on
your static website as a Pulumi-managed resource. So a subsequent `pulumi update` where the
your static website as a Pulumi-managed resource. So a subsequent `pulumi up` where the
file's contents have changed will result in an update to the `aws.s3.BucketObject` resource.

Note how the `contentType` property is set by calling the NPM package [mime](https://www.npmjs.com/package/mime).
Expand Down Expand Up @@ -114,7 +113,7 @@ changes.
It may be more efficient to not manage individual files using Pulumi and and instead just use the
AWS CLI to sync local files with the S3 bucket directly.

Remove the call to `crawlDirectory` and run `pulumi update`. Pulumi will then delete the contents
Remove the call to `crawlDirectory` and run `pulumi up`. Pulumi will then delete the contents
of the S3 bucket, and no longer manage their contents. Then do a bulk upload outside of Pulumi
using the AWS CLI.

Expand Down
2 changes: 1 addition & 1 deletion aws-ts-static-website/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async function createAliasRecord(

const aRecord = createAliasRecord(config.targetDomain, cdn);

// Export properties from this stack. This prints them at the end of `pulumi update` and
// Export properties from this stack. This prints them at the end of `pulumi up` and
// makes them easier to access from the pulumi.com.
export const contentBucketUri = contentBucket.bucket.apply(b => `s3:https://${b}`);
export const contentBucketWebsiteEndpoint = contentBucket.websiteEndpoint;
Expand Down
7 changes: 0 additions & 7 deletions aws-ts-static-website/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "aws-static-website-example",
"main": "bin/index.js",
"typings": "bin/index.d.ts",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"tslint": "^5.10.0",
"typescript": "^2.7.2",
"@types/mime": "^2.0.0",
"@types/node": "latest"
},
Expand Down
Loading

0 comments on commit f533be1

Please sign in to comment.