forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
33 lines (27 loc) · 1.1 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as gcp from "@pulumi/gcp";
/**
* Deploy a function using the default runtime.
*/
const greeting = new gcp.cloudfunctions.HttpCallbackFunction("greeting", (req: any, res: any) => {
res.send(`Greetings from ${req.body.name || "Google Cloud Functions"}!`);
});
const invoker = new gcp.cloudfunctions.FunctionIamMember("invoker", {
project: greeting.function.project,
region: greeting.function.region,
cloudFunction: greeting.function.name,
role: "roles/cloudfunctions.invoker",
member: "allUsers",
});
export const url = greeting.httpsTriggerUrl;
/**
* Deploy a function using an explicitly set runtime.
*/
const runtime = "nodejs14"; // https://cloud.google.com/functions/docs/concepts/exec#runtimes
const explicitRuntimeGreeting = new gcp.cloudfunctions.HttpCallbackFunction(`greeting-${runtime}`, {
runtime: runtime,
callback: (req: any, res: any) => {
res.send(`Greetings from ${req.body.name || "Google Cloud Functions"}!`);
},
});
export const nodejs14Url = explicitRuntimeGreeting.httpsTriggerUrl;