Is the backend service created in google cloud compute via Pulumi global?

37 views Asked by At

I want to perform this step via Pulumi:

gcloud compute backend-services create --global $BACKEND_NAME

This is how I am doing it:

backend_service = compute.BackendService(
    backend_name,
    project=gcp_project,
    backends=backends,
    enable_cdn=True,
    port_name="http",
    protocol="HTTP"
)

From the documentation, it mentions that:

This resource is a global backend service,

Does it mean, the code I have shared, creates the backend service for 'global'?

1

There are 1 answers

0
Dion V On

Yes the code you shared creates a backend service for 'global' and you can try to use this typscript as a guide

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

let backendService = new gcp.compute.BackendService("backendService", {
    enableCdn: true,
    portName: "http",
    protocol: "HTTP",
    backends: [
        {
            group: "my-instance-group", // replace with your instance group
            balancingMode: "UTILIZATION",
            capacityScaler: 1,
            maxUtilization: 0.8,
            maxRatePerInstance: 1,
        },
    ],
    cdnPolicy: {
        cacheKeyPolicy: {
            includeHost: true,
            includeProtocol: true,
            includeQueryString: true,
        },
    },
    project: "my-gcp-project", // replace with your project id
});

// Export the name of the backend service
export const backendServiceName = backendService.name;

As a reference, you can check this documentation. or for this reference.