pulumi_wasm_providers_gcp_mini::compute

Module region_backend_service

source
Expand description

A Region Backend Service defines a regionally-scoped group of virtual machines that will serve traffic for load balancing.

To get more information about RegionBackendService, see:

§Example Usage

§Region Backend Service Basic

resources:
  default:
    type: gcp:compute:RegionBackendService
    properties:
      name: region-service
      region: us-central1
      healthChecks: ${defaultHealthCheck.id}
      connectionDrainingTimeoutSec: 10
      sessionAffinity: CLIENT_IP
  defaultHealthCheck:
    type: gcp:compute:HealthCheck
    name: default
    properties:
      name: rbs-health-check
      checkIntervalSec: 1
      timeoutSec: 1
      tcpHealthCheck:
        port: '80'

§Region Backend Service External Iap

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .iap(
                RegionBackendServiceIap::builder()
                    .enabled(true)
                    .oauth2ClientId("abc")
                    .oauth2ClientSecret("xyz")
                    .build_struct(),
            )
            .load_balancing_scheme("EXTERNAL")
            .name("tf-test-region-service-external")
            .protocol("HTTP")
            .region("us-central1")
            .build_struct(),
    );
}

§Region Backend Service Cache

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .cdn_policy(
                RegionBackendServiceCdnPolicy::builder()
                    .cacheMode("CACHE_ALL_STATIC")
                    .clientTtl(7200)
                    .defaultTtl(3600)
                    .maxTtl(10800)
                    .negativeCaching(true)
                    .signedUrlCacheMaxAgeSec(7200)
                    .build_struct(),
            )
            .enable_cdn(true)
            .health_checks("${defaultRegionHealthCheck.id}")
            .load_balancing_scheme("EXTERNAL")
            .name("region-service")
            .protocol("HTTP")
            .region("us-central1")
            .build_struct(),
    );
    let defaultRegionHealthCheck = region_health_check::create(
        "defaultRegionHealthCheck",
        RegionHealthCheckArgs::builder()
            .http_health_check(
                RegionHealthCheckHttpHealthCheck::builder().port(80).build_struct(),
            )
            .name("rbs-health-check")
            .region("us-central1")
            .build_struct(),
    );
}

§Region Backend Service Ilb Round Robin

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .health_checks("${healthCheck.id}")
            .load_balancing_scheme("INTERNAL_MANAGED")
            .locality_lb_policy("ROUND_ROBIN")
            .name("region-service")
            .protocol("HTTP")
            .region("us-central1")
            .build_struct(),
    );
    let healthCheck = health_check::create(
        "healthCheck",
        HealthCheckArgs::builder()
            .http_health_check(
                HealthCheckHttpHealthCheck::builder().port(80).build_struct(),
            )
            .name("rbs-health-check")
            .build_struct(),
    );
}

§Region Backend Service External

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .health_checks("${healthCheck.id}")
            .load_balancing_scheme("EXTERNAL")
            .name("region-service")
            .protocol("TCP")
            .region("us-central1")
            .build_struct(),
    );
    let healthCheck = region_health_check::create(
        "healthCheck",
        RegionHealthCheckArgs::builder()
            .name("rbs-health-check")
            .region("us-central1")
            .tcp_health_check(
                RegionHealthCheckTcpHealthCheck::builder().port(80).build_struct(),
            )
            .build_struct(),
    );
}

§Region Backend Service External Weighted

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .health_checks("${healthCheck.id}")
            .load_balancing_scheme("EXTERNAL")
            .locality_lb_policy("WEIGHTED_MAGLEV")
            .name("region-service")
            .protocol("TCP")
            .region("us-central1")
            .build_struct(),
    );
    let healthCheck = region_health_check::create(
        "healthCheck",
        RegionHealthCheckArgs::builder()
            .http_health_check(
                RegionHealthCheckHttpHealthCheck::builder().port(80).build_struct(),
            )
            .name("rbs-health-check")
            .region("us-central1")
            .build_struct(),
    );
}

§Region Backend Service Ilb Ring Hash

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .circuit_breakers(
                RegionBackendServiceCircuitBreakers::builder()
                    .maxConnections(10)
                    .build_struct(),
            )
            .consistent_hash(
                RegionBackendServiceConsistentHash::builder()
                    .httpCookie(
                        RegionBackendServiceConsistentHashHttpCookie::builder()
                            .name("mycookie")
                            .ttl(
                                RegionBackendServiceConsistentHashHttpCookieTtl::builder()
                                    .nanos(1111)
                                    .seconds(11)
                                    .build_struct(),
                            )
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .health_checks("${healthCheck.id}")
            .load_balancing_scheme("INTERNAL_MANAGED")
            .locality_lb_policy("RING_HASH")
            .name("region-service")
            .outlier_detection(
                RegionBackendServiceOutlierDetection::builder()
                    .consecutiveErrors(2)
                    .build_struct(),
            )
            .protocol("HTTP")
            .region("us-central1")
            .session_affinity("HTTP_COOKIE")
            .build_struct(),
    );
    let healthCheck = health_check::create(
        "healthCheck",
        HealthCheckArgs::builder()
            .http_health_check(
                HealthCheckHttpHealthCheck::builder().port(80).build_struct(),
            )
            .name("rbs-health-check")
            .build_struct(),
    );
}

§Region Backend Service Ilb Stateful Session Affinity

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .health_checks("${healthCheck.id}")
            .load_balancing_scheme("INTERNAL_MANAGED")
            .locality_lb_policy("RING_HASH")
            .name("region-service")
            .protocol("HTTP")
            .region("us-central1")
            .session_affinity("STRONG_COOKIE_AFFINITY")
            .strong_session_affinity_cookie(
                RegionBackendServiceStrongSessionAffinityCookie::builder()
                    .name("mycookie")
                    .ttl(
                        RegionBackendServiceStrongSessionAffinityCookieTtl::builder()
                            .nanos(1111)
                            .seconds(11)
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .build_struct(),
    );
    let healthCheck = health_check::create(
        "healthCheck",
        HealthCheckArgs::builder()
            .http_health_check(
                HealthCheckHttpHealthCheck::builder().port(80).build_struct(),
            )
            .name("rbs-health-check")
            .build_struct(),
    );
}

§Region Backend Service Balancing Mode

resources:
  default:
    type: gcp:compute:RegionBackendService
    properties:
      loadBalancingScheme: INTERNAL_MANAGED
      backends:
        - group: ${rigm.instanceGroup}
          balancingMode: UTILIZATION
          capacityScaler: 1
      region: us-central1
      name: region-service
      protocol: HTTP
      timeoutSec: 10
      healthChecks: ${defaultRegionHealthCheck.id}
  rigm:
    type: gcp:compute:RegionInstanceGroupManager
    properties:
      region: us-central1
      name: rbs-rigm
      versions:
        - instanceTemplate: ${instanceTemplate.id}
          name: primary
      baseInstanceName: internal-glb
      targetSize: 1
  instanceTemplate:
    type: gcp:compute:InstanceTemplate
    name: instance_template
    properties:
      name: template-region-service
      machineType: e2-medium
      networkInterfaces:
        - network: ${defaultNetwork.id}
          subnetwork: ${defaultSubnetwork.id}
      disks:
        - sourceImage: ${debianImage.selfLink}
          autoDelete: true
          boot: true
      tags:
        - allow-ssh
        - load-balanced-backend
  defaultRegionHealthCheck:
    type: gcp:compute:RegionHealthCheck
    name: default
    properties:
      region: us-central1
      name: rbs-health-check
      httpHealthCheck:
        portSpecification: USE_SERVING_PORT
  defaultNetwork:
    type: gcp:compute:Network
    name: default
    properties:
      name: rbs-net
      autoCreateSubnetworks: false
      routingMode: REGIONAL
  defaultSubnetwork:
    type: gcp:compute:Subnetwork
    name: default
    properties:
      name: rbs-net-default
      ipCidrRange: 10.1.2.0/24
      region: us-central1
      network: ${defaultNetwork.id}
variables:
  debianImage:
    fn::invoke:
      function: gcp:compute:getImage
      arguments:
        family: debian-11
        project: debian-cloud

§Region Backend Service Connection Tracking

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .connection_draining_timeout_sec(10)
            .connection_tracking_policy(
                RegionBackendServiceConnectionTrackingPolicy::builder()
                    .connectionPersistenceOnUnhealthyBackends("NEVER_PERSIST")
                    .enableStrongAffinity(true)
                    .idleTimeoutSec(60)
                    .trackingMode("PER_SESSION")
                    .build_struct(),
            )
            .health_checks("${healthCheck.id}")
            .load_balancing_scheme("EXTERNAL")
            .name("region-service")
            .protocol("TCP")
            .region("us-central1")
            .session_affinity("CLIENT_IP")
            .build_struct(),
    );
    let healthCheck = region_health_check::create(
        "healthCheck",
        RegionHealthCheckArgs::builder()
            .name("rbs-health-check")
            .region("us-central1")
            .tcp_health_check(
                RegionHealthCheckTcpHealthCheck::builder().port(22).build_struct(),
            )
            .build_struct(),
    );
}

§Region Backend Service Ip Address Selection Policy

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let default = region_backend_service::create(
        "default",
        RegionBackendServiceArgs::builder()
            .health_checks("${healthCheck.id}")
            .ip_address_selection_policy("IPV6_ONLY")
            .load_balancing_scheme("EXTERNAL_MANAGED")
            .name("region-service")
            .protocol("HTTP")
            .region("us-central1")
            .build_struct(),
    );
    let healthCheck = region_health_check::create(
        "healthCheck",
        RegionHealthCheckArgs::builder()
            .name("rbs-health-check")
            .region("us-central1")
            .tcp_health_check(
                RegionHealthCheckTcpHealthCheck::builder().port(80).build_struct(),
            )
            .build_struct(),
    );
}

§Import

RegionBackendService can be imported using any of these accepted formats:

  • projects/{{project}}/regions/{{region}}/backendServices/{{name}}

  • {{project}}/{{region}}/{{name}}

  • {{region}}/{{name}}

  • {{name}}

When using the pulumi import command, RegionBackendService can be imported using one of the formats above. For example:

$ pulumi import gcp:compute/regionBackendService:RegionBackendService default projects/{{project}}/regions/{{region}}/backendServices/{{name}}
$ pulumi import gcp:compute/regionBackendService:RegionBackendService default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/regionBackendService:RegionBackendService default {{region}}/{{name}}
$ pulumi import gcp:compute/regionBackendService:RegionBackendService default {{name}}

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments