https://pulumi.com logo
#google-cloud
Title
# google-cloud
a

ancient-park-44711

09/18/2023, 2:30 PM
Hello All! Has anyone else been able to get a Google Cloud function to deploy using Pulumi? It seems to be defaulting to NodeV8, which is no longer supported by Google Cloud. Is there a way to change the Node version when creating the function?
g

glamorous-jelly-86558

09/18/2023, 3:24 PM
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const bucket = new gcp.storage.Bucket("bucket", {location: "US"});
const archive = new gcp.storage.BucketObject("archive", {
    bucket: bucket.name,
    source: new pulumi.asset.FileAsset("./path/to/zip/file/which/contains/code"),
});
const _function = new gcp.cloudfunctions.Function("function", {
    description: "My function",
    runtime: "nodejs16",
    availableMemoryMb: 128,
    sourceArchiveBucket: bucket.name,
    sourceArchiveObject: archive.name,
    triggerHttp: true,
    entryPoint: "helloGET",
});
// IAM entry for all users to invoke the function
const invoker = new gcp.cloudfunctions.FunctionIamMember("invoker", {
    project: _function.project,
    region: _function.region,
    cloudFunction: _function.name,
    role: "roles/cloudfunctions.invoker",
    member: "allUsers",
});
Source: https://www.pulumi.com/registry/packages/gcp/api-docs/cloudfunctions/function/
runtime: "nodejs16",
<-- this line seems like the line you want to tweak
Here are the available options for that value: https://cloud.google.com/functions/docs/concepts/execution-environment
a

ancient-park-44711

09/18/2023, 5:49 PM
Paul - thanks so much for that. And most importantly, a pointer to the docs (I'll use that first next time). Much appreciated!
g

glamorous-jelly-86558

09/18/2023, 7:38 PM
Oh, also… it looks like there’s a
cloudfunctionsv2
resource type: https://www.pulumi.com/registry/packages/gcp/api-docs/cloudfunctionsv2/function/
3 Views