@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
555 lines • 21.6 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.BackendService = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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.
*
* 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)
*
* > **Warning:** All arguments including the following potentially sensitive
* values will be stored in the raw state as plain text: `iap.oauth2_client_secret`, `iap.oauth2_client_secret_sha256`, `security_settings.aws_v4_authentication.access_key`.
*
* ## 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 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",
* });
* ```
* ### 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,
* },
* ],
* }],
* });
* ```
* ### 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}`,
* },
* });
* ```
*
* ## 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}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/backendService:BackendService default {{project}}/{{name}}
* ```
*
* ```sh
* $ 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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.affinityCookieTtlSec : undefined;
resourceInputs["backends"] = state ? state.backends : undefined;
resourceInputs["cdnPolicy"] = state ? state.cdnPolicy : undefined;
resourceInputs["circuitBreakers"] = state ? state.circuitBreakers : undefined;
resourceInputs["compressionMode"] = state ? state.compressionMode : undefined;
resourceInputs["connectionDrainingTimeoutSec"] = state ? state.connectionDrainingTimeoutSec : undefined;
resourceInputs["consistentHash"] = state ? state.consistentHash : undefined;
resourceInputs["creationTimestamp"] = state ? state.creationTimestamp : undefined;
resourceInputs["customMetrics"] = state ? state.customMetrics : undefined;
resourceInputs["customRequestHeaders"] = state ? state.customRequestHeaders : undefined;
resourceInputs["customResponseHeaders"] = state ? state.customResponseHeaders : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["edgeSecurityPolicy"] = state ? state.edgeSecurityPolicy : undefined;
resourceInputs["enableCdn"] = state ? state.enableCdn : undefined;
resourceInputs["fingerprint"] = state ? state.fingerprint : undefined;
resourceInputs["generatedId"] = state ? state.generatedId : undefined;
resourceInputs["healthChecks"] = state ? state.healthChecks : undefined;
resourceInputs["iap"] = state ? state.iap : undefined;
resourceInputs["ipAddressSelectionPolicy"] = state ? state.ipAddressSelectionPolicy : undefined;
resourceInputs["loadBalancingScheme"] = state ? state.loadBalancingScheme : undefined;
resourceInputs["localityLbPolicies"] = state ? state.localityLbPolicies : undefined;
resourceInputs["localityLbPolicy"] = state ? state.localityLbPolicy : undefined;
resourceInputs["logConfig"] = state ? state.logConfig : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["outlierDetection"] = state ? state.outlierDetection : undefined;
resourceInputs["portName"] = state ? state.portName : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["protocol"] = state ? state.protocol : undefined;
resourceInputs["securityPolicy"] = state ? state.securityPolicy : undefined;
resourceInputs["securitySettings"] = state ? state.securitySettings : undefined;
resourceInputs["selfLink"] = state ? state.selfLink : undefined;
resourceInputs["serviceLbPolicy"] = state ? state.serviceLbPolicy : undefined;
resourceInputs["sessionAffinity"] = state ? state.sessionAffinity : undefined;
resourceInputs["strongSessionAffinityCookie"] = state ? state.strongSessionAffinityCookie : undefined;
resourceInputs["timeoutSec"] = state ? state.timeoutSec : undefined;
resourceInputs["tlsSettings"] = state ? state.tlsSettings : undefined;
}
else {
const args = argsOrState;
resourceInputs["affinityCookieTtlSec"] = args ? args.affinityCookieTtlSec : undefined;
resourceInputs["backends"] = args ? args.backends : undefined;
resourceInputs["cdnPolicy"] = args ? args.cdnPolicy : undefined;
resourceInputs["circuitBreakers"] = args ? args.circuitBreakers : undefined;
resourceInputs["compressionMode"] = args ? args.compressionMode : undefined;
resourceInputs["connectionDrainingTimeoutSec"] = args ? args.connectionDrainingTimeoutSec : undefined;
resourceInputs["consistentHash"] = args ? args.consistentHash : undefined;
resourceInputs["customMetrics"] = args ? args.customMetrics : undefined;
resourceInputs["customRequestHeaders"] = args ? args.customRequestHeaders : undefined;
resourceInputs["customResponseHeaders"] = args ? args.customResponseHeaders : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["edgeSecurityPolicy"] = args ? args.edgeSecurityPolicy : undefined;
resourceInputs["enableCdn"] = args ? args.enableCdn : undefined;
resourceInputs["healthChecks"] = args ? args.healthChecks : undefined;
resourceInputs["iap"] = args ? args.iap : undefined;
resourceInputs["ipAddressSelectionPolicy"] = args ? args.ipAddressSelectionPolicy : undefined;
resourceInputs["loadBalancingScheme"] = args ? args.loadBalancingScheme : undefined;
resourceInputs["localityLbPolicies"] = args ? args.localityLbPolicies : undefined;
resourceInputs["localityLbPolicy"] = args ? args.localityLbPolicy : undefined;
resourceInputs["logConfig"] = args ? args.logConfig : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["outlierDetection"] = args ? args.outlierDetection : undefined;
resourceInputs["portName"] = args ? args.portName : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["protocol"] = args ? args.protocol : undefined;
resourceInputs["securityPolicy"] = args ? args.securityPolicy : undefined;
resourceInputs["securitySettings"] = args ? args.securitySettings : undefined;
resourceInputs["serviceLbPolicy"] = args ? args.serviceLbPolicy : undefined;
resourceInputs["sessionAffinity"] = args ? args.sessionAffinity : undefined;
resourceInputs["strongSessionAffinityCookie"] = args ? args.strongSessionAffinityCookie : undefined;
resourceInputs["timeoutSec"] = args ? args.timeoutSec : undefined;
resourceInputs["tlsSettings"] = args ? args.tlsSettings : undefined;
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;
/** @internal */
BackendService.__pulumiType = 'gcp:compute/backendService:BackendService';
//# sourceMappingURL=backendService.js.map