Skip to content

Commit 2153a2e

Browse files
authored
Update GCP function example to new APIs (pulumi#270)
1 parent b853d2d commit 2153a2e

File tree

3 files changed

+27
-62
lines changed

3 files changed

+27
-62
lines changed

gcp-ts-functions/README.md

+24-10
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,36 @@
22

33
# GCP Functions
44

5-
An example Pulumi component that deploys a TypeScript function to Google Cloud Functions.
5+
An example of deploying an HTTP Google Cloud Function endpoint using TypeScript.
6+
7+
## Prerequisites
8+
9+
0. [Ensure you have the latest Node.js and NPM](https://nodejs.org/en/download/)
10+
2. [Install the Pulumi CLI](https://pulumi.io/quickstart/install.html)
11+
3. [Configure Pulumi to access your GCP account](https://pulumi.io/quickstart/gcp/setup.html)
612

713
## Running the App
814

9-
1. Create a new stack:
15+
1. Restore NPM dependencies:
1016

1117
```
12-
$ pulumi stack init gcp-fn
18+
$ npm install
1319
```
1420
15-
1. Configure GCP project and region:
21+
2. Create a new stack:
1622
1723
```
18-
$ pulumi config set gcp:project <projectname>
19-
$ pulumi config set gcp:region <region>
24+
$ pulumi stack init gcp-fn
2025
```
2126
22-
1. Restore NPM dependencies:
27+
3. Configure your GCP project and region:
2328
2429
```
25-
$ npm install
30+
$ pulumi config set gcp:project <projectname>
31+
$ pulumi config set gcp:region <region>
2632
```
2733
28-
1. Run `pulumi up` to preview and deploy changes:
34+
4. Run `pulumi up` to preview and deploy changes:
2935
3036
```
3137
$ pulumi up
@@ -39,12 +45,20 @@ An example Pulumi component that deploys a TypeScript function to Google Cloud F
3945
Update duration: 39.65130324s
4046
```
4147
42-
1. Check the deployed function endpoint:
48+
5. Check the deployed function endpoint:
4349
4450
```
4551
$ pulumi stack output url
4652
https://us-central1-pulumi-development.cloudfunctions.net/greeting-function-7f95447
4753
$ curl "$(pulumi stack output url)"
4854
Greetings from Google Cloud Functions!
55+
```
56+
57+
6. Clean up your GCP and Pulumi resources:
58+
59+
```
60+
$ pulumi destroy
61+
...
62+
$ pulumi stack rm
4963
...
5064
```

gcp-ts-functions/gcpFunction.ts

-49
This file was deleted.

gcp-ts-functions/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as gcpFunction from "./gcpFunction";
1+
import * as gcp from "@pulumi/gcp";
22

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

7-
export let url = greetingFunction.httpsTriggerUrl;
7+
export let url = greeting.httpsTriggerUrl;

0 commit comments

Comments
 (0)