pulumi_wasm_providers_gcp_mini::compute

Module backend_bucket

source
Expand description

Backend buckets allow you to use Google Cloud Storage buckets with HTTP(S) load balancing.

An HTTP(S) load balancer can direct traffic to specified URLs to a backend bucket rather than a backend service. It can send requests for static content to a Cloud Storage bucket and requests for dynamic content to a virtual machine instance.

To get more information about BackendBucket, see:

§Example Usage

§Backend Bucket Basic

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let imageBackend = backend_bucket::create(
        "imageBackend",
        BackendBucketArgs::builder()
            .bucket_name("${imageBucket.name}")
            .description("Contains beautiful images")
            .enable_cdn(true)
            .name("image-backend-bucket")
            .build_struct(),
    );
    let imageBucket = bucket::create(
        "imageBucket",
        BucketArgs::builder().location("EU").name("image-store-bucket").build_struct(),
    );
}

§Backend Bucket Security Policy

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let imageBackend = backend_bucket::create(
        "imageBackend",
        BackendBucketArgs::builder()
            .bucket_name("${imageBackendBucket.name}")
            .description("Contains beautiful images")
            .edge_security_policy("${policy.id}")
            .enable_cdn(true)
            .name("image-backend-bucket")
            .build_struct(),
    );
    let imageBackendBucket = bucket::create(
        "imageBackendBucket",
        BucketArgs::builder().location("EU").name("image-store-bucket").build_struct(),
    );
    let policy = security_policy::create(
        "policy",
        SecurityPolicyArgs::builder()
            .description("basic security policy")
            .name("image-store-bucket")
            .type_("CLOUD_ARMOR_EDGE")
            .build_struct(),
    );
}

§Backend Bucket Query String Whitelist

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let imageBackend = backend_bucket::create(
        "imageBackend",
        BackendBucketArgs::builder()
            .bucket_name("${imageBucket.name}")
            .cdn_policy(
                BackendBucketCdnPolicy::builder()
                    .cacheKeyPolicy(
                        BackendBucketCdnPolicyCacheKeyPolicy::builder()
                            .queryStringWhitelists(vec!["image-version",])
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .description("Contains beautiful images")
            .enable_cdn(true)
            .name("image-backend-bucket")
            .build_struct(),
    );
    let imageBucket = bucket::create(
        "imageBucket",
        BucketArgs::builder().location("EU").name("image-backend-bucket").build_struct(),
    );
}

§Backend Bucket Include Http Headers

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let imageBackend = backend_bucket::create(
        "imageBackend",
        BackendBucketArgs::builder()
            .bucket_name("${imageBucket.name}")
            .cdn_policy(
                BackendBucketCdnPolicy::builder()
                    .cacheKeyPolicy(
                        BackendBucketCdnPolicyCacheKeyPolicy::builder()
                            .includeHttpHeaders(vec!["X-My-Header-Field",])
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .description("Contains beautiful images")
            .enable_cdn(true)
            .name("image-backend-bucket")
            .build_struct(),
    );
    let imageBucket = bucket::create(
        "imageBucket",
        BucketArgs::builder().location("EU").name("image-backend-bucket").build_struct(),
    );
}

§Import

BackendBucket can be imported using any of these accepted formats:

  • projects/{{project}}/global/backendBuckets/{{name}}

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

  • {{name}}

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

$ pulumi import gcp:compute/backendBucket:BackendBucket default projects/{{project}}/global/backendBuckets/{{name}}
$ pulumi import gcp:compute/backendBucket:BackendBucket default {{project}}/{{name}}
$ pulumi import gcp:compute/backendBucket:BackendBucket default {{name}}

Structs§

Functions§

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