Skip to content

Commit

Permalink
Update GCP function example to new APIs (pulumi#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeduffy committed Apr 4, 2019
1 parent b853d2d commit 2153a2e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 62 deletions.
34 changes: 24 additions & 10 deletions gcp-ts-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@

# GCP Functions

An example Pulumi component that deploys a TypeScript function to Google Cloud Functions.
An example of deploying an HTTP Google Cloud Function endpoint using TypeScript.

## Prerequisites

0. [Ensure you have the latest Node.js and NPM](https://nodejs.org/en/download/)
2. [Install the Pulumi CLI](https://pulumi.io/quickstart/install.html)
3. [Configure Pulumi to access your GCP account](https://pulumi.io/quickstart/gcp/setup.html)

## Running the App

1. Create a new stack:
1. Restore NPM dependencies:

```
$ pulumi stack init gcp-fn
$ npm install
```

1. Configure GCP project and region:
2. Create a new stack:

```
$ pulumi config set gcp:project <projectname>
$ pulumi config set gcp:region <region>
$ pulumi stack init gcp-fn
```

1. Restore NPM dependencies:
3. Configure your GCP project and region:

```
$ npm install
$ pulumi config set gcp:project <projectname>
$ pulumi config set gcp:region <region>
```

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

```
$ pulumi up
Expand All @@ -39,12 +45,20 @@ An example Pulumi component that deploys a TypeScript function to Google Cloud F
Update duration: 39.65130324s
```

1. Check the deployed function endpoint:
5. Check the deployed function endpoint:

```
$ pulumi stack output url
https://us-central1-pulumi-development.cloudfunctions.net/greeting-function-7f95447
$ curl "$(pulumi stack output url)"
Greetings from Google Cloud Functions!
```

6. Clean up your GCP and Pulumi resources:

```
$ pulumi destroy
...
$ pulumi stack rm
...
```
49 changes: 0 additions & 49 deletions gcp-ts-functions/gcpFunction.ts

This file was deleted.

6 changes: 3 additions & 3 deletions gcp-ts-functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as gcpFunction from "./gcpFunction";
import * as gcp from "@pulumi/gcp";

let greetingFunction = new gcpFunction.HttpFunction("greeting", (req, res) => {
let greeting = new gcp.cloudfunctions.HttpCallbackFunction("greeting", (req, res) => {
res.send(`Greetings from ${req.body.name || 'Google Cloud Functions'}!`);
});

export let url = greetingFunction.httpsTriggerUrl;
export let url = greeting.httpsTriggerUrl;

0 comments on commit 2153a2e

Please sign in to comment.