UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

676 lines • 25.2 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BackendService = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * A Backend Service defines a group of virtual machines that will serve * traffic for load balancing. This resource is a global backend service, * appropriate for external load balancing or self-managed internal load balancing. * For managed internal load balancing, use a regional backend service instead. * * Currently self-managed internal load balancing is only available in beta. * * > **Note:** Recreating a `gcp.compute.BackendService` that references other dependent resources like `gcp.compute.URLMap` will give a `resourceInUseByAnotherResource` error, when modifying the number of other dependent resources. * Use `lifecycle.create_before_destroy` on the dependent resources to avoid this type of error as shown in the Dynamic Backends example. * * To get more information about BackendService, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/v1/backendServices) * * How-to Guides * * [Official Documentation](https://cloud.google.com/compute/docs/load-balancing/http/backend-service) * * ## Example Usage * * ### Backend Service Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", { * name: "health-check", * requestPath: "/", * checkIntervalSec: 1, * timeoutSec: 1, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHttpHealthCheck.id, * }); * ``` * ### Backend Service External Iap * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.BackendService("default", { * name: "tf-test-backend-service-external", * protocol: "HTTP", * loadBalancingScheme: "EXTERNAL", * iap: { * enabled: true, * oauth2ClientId: "abc", * oauth2ClientSecret: "xyz", * }, * }); * ``` * ### Backend Service Cache Simple * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", { * name: "health-check", * requestPath: "/", * checkIntervalSec: 1, * timeoutSec: 1, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHttpHealthCheck.id, * enableCdn: true, * cdnPolicy: { * signedUrlCacheMaxAgeSec: 7200, * }, * }); * ``` * ### Backend Service Cache Include Http Headers * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * enableCdn: true, * cdnPolicy: { * cacheMode: "USE_ORIGIN_HEADERS", * cacheKeyPolicy: { * includeHost: true, * includeProtocol: true, * includeQueryString: true, * includeHttpHeaders: ["X-My-Header-Field"], * }, * }, * }); * ``` * ### Backend Service Cache Include Named Cookies * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * enableCdn: true, * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: 3600, * clientTtl: 7200, * maxTtl: 10800, * cacheKeyPolicy: { * includeHost: true, * includeProtocol: true, * includeQueryString: true, * includeNamedCookies: [ * "__next_preview_data", * "__prerender_bypass", * ], * }, * }, * }); * ``` * ### Backend Service Cache * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", { * name: "health-check", * requestPath: "/", * checkIntervalSec: 1, * timeoutSec: 1, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHttpHealthCheck.id, * enableCdn: true, * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: 3600, * clientTtl: 7200, * maxTtl: 10800, * negativeCaching: true, * signedUrlCacheMaxAgeSec: 7200, * }, * }); * ``` * ### Backend Service Cache Bypass Cache On Request Headers * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("default", { * name: "health-check", * requestPath: "/", * checkIntervalSec: 1, * timeoutSec: 1, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHttpHealthCheck.id, * enableCdn: true, * cdnPolicy: { * cacheMode: "CACHE_ALL_STATIC", * defaultTtl: 3600, * clientTtl: 7200, * maxTtl: 10800, * negativeCaching: true, * signedUrlCacheMaxAgeSec: 7200, * bypassCacheOnRequestHeaders: [ * { * headerName: "Authorization", * }, * { * headerName: "Proxy-Authorization", * }, * ], * }, * }); * ``` * ### Backend Service Traffic Director Round Robin * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const healthCheck = new gcp.compute.HealthCheck("health_check", { * name: "health-check", * httpHealthCheck: { * port: 80, * }, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: healthCheck.id, * loadBalancingScheme: "INTERNAL_SELF_MANAGED", * localityLbPolicy: "ROUND_ROBIN", * }); * ``` * ### Backend Service Traffic Director Ring Hash * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const healthCheck = new gcp.compute.HealthCheck("health_check", { * name: "health-check", * httpHealthCheck: { * port: 80, * }, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: healthCheck.id, * loadBalancingScheme: "INTERNAL_SELF_MANAGED", * localityLbPolicy: "RING_HASH", * sessionAffinity: "HTTP_COOKIE", * circuitBreakers: { * maxConnections: 10, * }, * consistentHash: { * httpCookie: { * ttl: { * seconds: 11, * nanos: 1111, * }, * name: "mycookie", * }, * }, * outlierDetection: { * consecutiveErrors: 2, * consecutiveGatewayFailure: 5, * enforcingConsecutiveErrors: 100, * enforcingConsecutiveGatewayFailure: 0, * enforcingSuccessRate: 100, * maxEjectionPercent: 10, * successRateMinimumHosts: 5, * successRateRequestVolume: 100, * successRateStdevFactor: 1900, * }, * }); * ``` * ### Backend Service Stateful Session Affinity * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const healthCheck = new gcp.compute.HealthCheck("health_check", { * name: "health-check", * httpHealthCheck: { * port: 80, * }, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: healthCheck.id, * loadBalancingScheme: "EXTERNAL_MANAGED", * localityLbPolicy: "RING_HASH", * sessionAffinity: "STRONG_COOKIE_AFFINITY", * strongSessionAffinityCookie: { * ttl: { * seconds: 11, * nanos: 1111, * }, * name: "mycookie", * }, * }); * ``` * ### Backend Service Network Endpoint * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const externalProxy = new gcp.compute.GlobalNetworkEndpointGroup("external_proxy", { * name: "network-endpoint", * networkEndpointType: "INTERNET_FQDN_PORT", * defaultPort: 443, * }); * const proxy = new gcp.compute.GlobalNetworkEndpoint("proxy", { * globalNetworkEndpointGroup: externalProxy.id, * fqdn: "test.example.com", * port: externalProxy.defaultPort, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * enableCdn: true, * timeoutSec: 10, * connectionDrainingTimeoutSec: 10, * customRequestHeaders: [proxy.fqdn.apply(fqdn => `host: ${fqdn}`)], * customResponseHeaders: ["X-Cache-Hit: {cdn_cache_status}"], * backends: [{ * group: externalProxy.id, * }], * }); * ``` * ### Backend Service In Flight * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const custom = new gcp.compute.Network("custom", { * name: "custom-vpc", * autoCreateSubnetworks: false, * }); * const _default = new gcp.compute.Subnetwork("default", { * name: "custom-subnet", * ipCidrRange: "10.0.0.0/24", * region: "us-central1", * network: custom.id, * }); * const defaultInstanceTemplate = new gcp.compute.InstanceTemplate("default", { * name: "instance-template", * machineType: "e2-micro", * disks: [{ * sourceImage: "debian-cloud/debian-11", * autoDelete: true, * boot: true, * }], * networkInterfaces: [{ * network: custom.id, * subnetwork: _default.id, * }], * metadata: { * "startup-script": `#!/bin/bash * echo \\"Hello World from MIG VM\\" > /var/www/html/index.html * apt-get update -y * apt-get install -y apache2 * systemctl start apache2 * `, * }, * }); * const foobar = new gcp.compute.RegionInstanceGroupManager("foobar", { * name: "instance-group-manager", * baseInstanceName: "vm", * region: "us-central1", * versions: [{ * instanceTemplate: defaultInstanceTemplate.id, * }], * targetSize: 1, * }); * const defaultHealthCheck = new gcp.compute.HealthCheck("default", { * name: "health-check", * httpHealthCheck: { * port: 80, * }, * }); * const defaultBackendService = new gcp.compute.BackendService("default", { * name: "backend-service", * description: "Hello World 1234", * portName: "http", * protocol: "TCP", * loadBalancingScheme: "EXTERNAL_MANAGED", * backends: [{ * group: foobar.instanceGroup, * balancingMode: "IN_FLIGHT", * maxInFlightRequests: 1000, * trafficDuration: "LONG", * }], * healthChecks: defaultHealthCheck.selfLink, * }); * ``` * ### Backend Service External Managed * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultHealthCheck = new gcp.compute.HealthCheck("default", { * name: "health-check", * httpHealthCheck: { * port: 80, * }, * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHealthCheck.id, * loadBalancingScheme: "EXTERNAL_MANAGED", * protocol: "H2C", * }); * ``` * ### Backend Service Ip Address Selection Policy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * loadBalancingScheme: "EXTERNAL_MANAGED", * ipAddressSelectionPolicy: "IPV6_ONLY", * }); * ``` * ### Backend Service Custom Metrics * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.Network("default", {name: "network"}); * // Zonal NEG with GCE_VM_IP_PORT * const defaultNetworkEndpointGroup = new gcp.compute.NetworkEndpointGroup("default", { * name: "network-endpoint", * network: _default.id, * defaultPort: 90, * zone: "us-central1-a", * networkEndpointType: "GCE_VM_IP_PORT", * }); * const defaultHealthCheck = new gcp.compute.HealthCheck("default", { * name: "health-check", * timeoutSec: 1, * checkIntervalSec: 1, * tcpHealthCheck: { * port: 80, * }, * }); * const defaultBackendService = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHealthCheck.id, * loadBalancingScheme: "EXTERNAL_MANAGED", * localityLbPolicy: "WEIGHTED_ROUND_ROBIN", * customMetrics: [{ * name: "orca.application_utilization", * dryRun: false, * }], * backends: [{ * group: defaultNetworkEndpointGroup.id, * balancingMode: "CUSTOM_METRICS", * customMetrics: [ * { * name: "orca.cpu_utilization", * maxUtilization: 0.9, * dryRun: true, * }, * { * name: "orca.named_metrics.foo", * dryRun: false, * }, * ], * }], * logConfig: { * enable: true, * optionalMode: "CUSTOM", * optionalFields: [ * "orca_load_report", * "tls.protocol", * ], * }, * }); * ``` * ### Backend Service Tls Settings * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const defaultHealthCheck = new gcp.compute.HealthCheck("default", { * name: "health-check", * httpHealthCheck: { * port: 80, * }, * }); * const defaultBackendAuthenticationConfig = new gcp.networksecurity.BackendAuthenticationConfig("default", { * name: "authentication", * wellKnownRoots: "PUBLIC_ROOTS", * }); * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * healthChecks: defaultHealthCheck.id, * loadBalancingScheme: "EXTERNAL_MANAGED", * protocol: "HTTPS", * tlsSettings: { * sni: "example.com", * subjectAltNames: [ * { * dnsName: "example.com", * }, * { * uniformResourceIdentifier: "https://example.com", * }, * ], * authenticationConfig: pulumi.interpolate`//networksecurity.googleapis.com/${defaultBackendAuthenticationConfig.id}`, * }, * }); * ``` * ### Backend Service Dynamic Forwarding * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.BackendService("default", { * name: "backend-service", * loadBalancingScheme: "INTERNAL_MANAGED", * dynamicForwarding: { * ipPortSelection: { * enabled: true, * }, * }, * }); * ``` * * ## Import * * BackendService can be imported using any of these accepted formats: * * * `projects/{{project}}/global/backendServices/{{name}}` * * `{{project}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, BackendService can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/backendService:BackendService default projects/{{project}}/global/backendServices/{{name}} * $ pulumi import gcp:compute/backendService:BackendService default {{project}}/{{name}} * $ pulumi import gcp:compute/backendService:BackendService default {{name}} * ``` */ class BackendService extends pulumi.CustomResource { /** * Get an existing BackendService resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new BackendService(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:compute/backendService:BackendService'; /** * Returns true if the given object is an instance of BackendService. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === BackendService.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["affinityCookieTtlSec"] = state?.affinityCookieTtlSec; resourceInputs["backends"] = state?.backends; resourceInputs["cdnPolicy"] = state?.cdnPolicy; resourceInputs["circuitBreakers"] = state?.circuitBreakers; resourceInputs["compressionMode"] = state?.compressionMode; resourceInputs["connectionDrainingTimeoutSec"] = state?.connectionDrainingTimeoutSec; resourceInputs["consistentHash"] = state?.consistentHash; resourceInputs["creationTimestamp"] = state?.creationTimestamp; resourceInputs["customMetrics"] = state?.customMetrics; resourceInputs["customRequestHeaders"] = state?.customRequestHeaders; resourceInputs["customResponseHeaders"] = state?.customResponseHeaders; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["description"] = state?.description; resourceInputs["dynamicForwarding"] = state?.dynamicForwarding; resourceInputs["edgeSecurityPolicy"] = state?.edgeSecurityPolicy; resourceInputs["enableCdn"] = state?.enableCdn; resourceInputs["externalManagedMigrationState"] = state?.externalManagedMigrationState; resourceInputs["externalManagedMigrationTestingPercentage"] = state?.externalManagedMigrationTestingPercentage; resourceInputs["fingerprint"] = state?.fingerprint; resourceInputs["generatedId"] = state?.generatedId; resourceInputs["healthChecks"] = state?.healthChecks; resourceInputs["iap"] = state?.iap; resourceInputs["ipAddressSelectionPolicy"] = state?.ipAddressSelectionPolicy; resourceInputs["loadBalancingScheme"] = state?.loadBalancingScheme; resourceInputs["localityLbPolicies"] = state?.localityLbPolicies; resourceInputs["localityLbPolicy"] = state?.localityLbPolicy; resourceInputs["logConfig"] = state?.logConfig; resourceInputs["maxStreamDuration"] = state?.maxStreamDuration; resourceInputs["name"] = state?.name; resourceInputs["networkPassThroughLbTrafficPolicy"] = state?.networkPassThroughLbTrafficPolicy; resourceInputs["outlierDetection"] = state?.outlierDetection; resourceInputs["params"] = state?.params; resourceInputs["portName"] = state?.portName; resourceInputs["project"] = state?.project; resourceInputs["protocol"] = state?.protocol; resourceInputs["securityPolicy"] = state?.securityPolicy; resourceInputs["securitySettings"] = state?.securitySettings; resourceInputs["selfLink"] = state?.selfLink; resourceInputs["serviceLbPolicy"] = state?.serviceLbPolicy; resourceInputs["sessionAffinity"] = state?.sessionAffinity; resourceInputs["strongSessionAffinityCookie"] = state?.strongSessionAffinityCookie; resourceInputs["timeoutSec"] = state?.timeoutSec; resourceInputs["tlsSettings"] = state?.tlsSettings; } else { const args = argsOrState; resourceInputs["affinityCookieTtlSec"] = args?.affinityCookieTtlSec; resourceInputs["backends"] = args?.backends; resourceInputs["cdnPolicy"] = args?.cdnPolicy; resourceInputs["circuitBreakers"] = args?.circuitBreakers; resourceInputs["compressionMode"] = args?.compressionMode; resourceInputs["connectionDrainingTimeoutSec"] = args?.connectionDrainingTimeoutSec; resourceInputs["consistentHash"] = args?.consistentHash; resourceInputs["customMetrics"] = args?.customMetrics; resourceInputs["customRequestHeaders"] = args?.customRequestHeaders; resourceInputs["customResponseHeaders"] = args?.customResponseHeaders; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["description"] = args?.description; resourceInputs["dynamicForwarding"] = args?.dynamicForwarding; resourceInputs["edgeSecurityPolicy"] = args?.edgeSecurityPolicy; resourceInputs["enableCdn"] = args?.enableCdn; resourceInputs["externalManagedMigrationState"] = args?.externalManagedMigrationState; resourceInputs["externalManagedMigrationTestingPercentage"] = args?.externalManagedMigrationTestingPercentage; resourceInputs["healthChecks"] = args?.healthChecks; resourceInputs["iap"] = args?.iap; resourceInputs["ipAddressSelectionPolicy"] = args?.ipAddressSelectionPolicy; resourceInputs["loadBalancingScheme"] = args?.loadBalancingScheme; resourceInputs["localityLbPolicies"] = args?.localityLbPolicies; resourceInputs["localityLbPolicy"] = args?.localityLbPolicy; resourceInputs["logConfig"] = args?.logConfig; resourceInputs["maxStreamDuration"] = args?.maxStreamDuration; resourceInputs["name"] = args?.name; resourceInputs["networkPassThroughLbTrafficPolicy"] = args?.networkPassThroughLbTrafficPolicy; resourceInputs["outlierDetection"] = args?.outlierDetection; resourceInputs["params"] = args?.params; resourceInputs["portName"] = args?.portName; resourceInputs["project"] = args?.project; resourceInputs["protocol"] = args?.protocol; resourceInputs["securityPolicy"] = args?.securityPolicy; resourceInputs["securitySettings"] = args?.securitySettings; resourceInputs["serviceLbPolicy"] = args?.serviceLbPolicy; resourceInputs["sessionAffinity"] = args?.sessionAffinity; resourceInputs["strongSessionAffinityCookie"] = args?.strongSessionAffinityCookie; resourceInputs["timeoutSec"] = args?.timeoutSec; resourceInputs["tlsSettings"] = args?.tlsSettings; resourceInputs["creationTimestamp"] = undefined /*out*/; resourceInputs["fingerprint"] = undefined /*out*/; resourceInputs["generatedId"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(BackendService.__pulumiType, name, resourceInputs, opts); } } exports.BackendService = BackendService; //# sourceMappingURL=backendService.js.map