GoogleComputeBackendBucket class final
Factory wrapper for google_compute_backend_bucket (provider
hashicorp/google ~> 7.0).
A global backend bucket — the load-balancing target that points
an HTTPS load balancer at a Google Cloud Storage bucket of static
objects. Use this when the load balancer needs to serve static
content (images, JS/CSS bundles, downloadable assets) directly out
of GCS without routing through a VM or serverless backend. Pair it
with a URL map (a google_compute_url_map path_matcher typically
has the form default_service = backendService and
path_rule = backendBucket for a /static/* prefix).
Required identity:
localName: Terraform local name (the address segment aftergoogle_compute_backend_bucket.).name: GCP resource name (1-63 chars, lowercase RFC1035).bucket_name: the name of an existing Cloud Storage bucket (e.g.'my-static-assets'). This is the bucket name only — not ags://URI and not the bucket's self-link. The bucket must exist in the same project and be readable by the load balancer's service identity (allUsers-readable for public CDN serving, or granted via the Cloud CDN signed-URL key for private content).
Cross-resource references:
edgeSecurityPolicyis the self-link of agoogle_compute_security_policyof typeCLOUD_ARMOR_EDGE(distinct from a regular Cloud Armor policy — edge policies attach at the load balancer's edge, ahead of the cache). Usevar.security_policy_idin real configs:edgeSecurityPolicy: TfArg.literal('projects/p/global/securityPolicies/edge-deny-all').- The compositional inverse is at a URL map: a
google_compute_url_map.path_rule.servicereferences this bucket's selfLink.
Example (CDN-fronted static assets with custom cache headers):
final assets = GoogleComputeBackendBucket(
localName: 'static_assets',
name: TfArg.literal('static-assets'),
bucketName: TfArg.literal('my-static-assets'),
enableCdn: TfArg.literal(true),
cdnPolicy: const ComputeBackendBucketBackendBucketCdnPolicy(
cacheMode: BackendBucketCacheMode.cacheAllStatic,
defaultTtl: 3600,
maxTtl: 86400,
clientTtl: 3600,
negativeCaching: true,
negativeCachingPolicy: [
ComputeBackendBucketBackendBucketCdnNegativeCachingPolicy(code: 404, ttl: 120),
ComputeBackendBucketBackendBucketCdnNegativeCachingPolicy(code: 410, ttl: 120),
],
serveWhileStale: 60,
),
customResponseHeaders: TfArg.literal([
'X-Cache: \$(cache_status)',
]),
compressionMode:
TfArg.literal(BackendBucketCompressionMode.automatic),
);
Example (private bucket fronted by Cloud Armor edge policy):
final secured = GoogleComputeBackendBucket(
localName: 'secured_assets',
name: TfArg.literal('secured-assets'),
bucketName: TfArg.literal('private-static-assets'),
enableCdn: TfArg.literal(true),
edgeSecurityPolicy: TfArg.literal(
// var.security_policy_id — a CLOUD_ARMOR_EDGE-typed
// google_compute_security_policy self-link.
'projects/p/global/securityPolicies/edge-rate-limit',
),
);
Nested-type prefix: every helper class for a cdn_policy sub-block
is BackendBucket-prefixed (e.g. ComputeBackendBucketBackendBucketCdnPolicy,
ComputeBackendBucketBackendBucketCdnCacheKeyPolicy,
ComputeBackendBucketBackendBucketCdnNegativeCachingPolicy,
ComputeBackendBucketBackendBucketCdnBypassCacheOnRequestHeader). The shape mirrors the
BackendService* family but is a distinct type — the bucket and
service CDN configurations are not interchangeable, even where the
schema field names agree.
Composition pattern: extends Resource<$GoogleComputeBackendBucket>
for runtime behavior.
Constructors
-
GoogleComputeBackendBucket({required String localName, required TfArg<
String> name, required TfArg<String> bucketName, TfArg<String> ? description, TfArg<bool> ? enableCdn, TfArg<BackendBucketCompressionMode> ? compressionMode, TfArg<List< ? customResponseHeaders, TfArg<String> >String> ? edgeSecurityPolicy, TfArg<BackendBucketLoadBalancingScheme> ? loadBalancingScheme, ComputeBackendBucketBackendBucketCdnPolicy? cdnPolicy, ComputeBackendBucketBackendBucketParams? params, TfArg<String> ? project, LifecycleOptions? lifecycle, List<DependencyTarget> ? dependsOn})
Properties
-
$sensitiveFields
→ Set<
String> -
Field names that are
@Sensitiveper the IR-derived per-resource constant. Curated factories override with a baked-instatic const Set<String>(file-private in v0.5+).no setter - $supportsDeletionProtection → bool
-
Capability flag: true when this resource's underlying Terraform
schema has a
deletion_protectionboolean attribute that the synth-time devMode flow can flip tofalse. Defaults to false; the codegen emitter overrides this totruefor wrappers whose schema includes the attribute.no setterinherited -
argMap
→ Map<
String, TfArg?> -
Argument-name → TfArg map. Keys are snake_case (Terraform JSON name).
Synth emits these keys directly; the factory is responsible for the
camelCase → snake_case translation at construction time.
finalinherited
-
creationTimestamp
→ TfRef<
String> -
Reference to
creation_timestamp(RFC3339).no setter -
dependsOn
→ List<
DependencyTarget> ? -
Optional
depends_on = [...]. Each entry is aDependencyTarget— either a wholesale resource (rendered as bare address) or an explicitTfRef(rendered viabareAddress).finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
→ TfRef<
String> -
Reference to
idattribute (full pathprojects/{project}/global/backendBuckets/{name}).no setter - kind → ResourceKind
-
Always
ResourceKind.resource. Overridden byData.no setterinherited - lifecycle → LifecycleOptions?
-
Optional
lifecycle { ... }block.finalinherited - localName → String
-
User-supplied local name within a Stack.
finalinherited
-
nameRef
→ TfRef<
String> -
Reference to
nameattribute.no setter - provider → ProviderBinding?
-
Optional explicit provider binding. Only the type is referenced here;
the concrete
Providerclass lives interradart_google(provider classes are defined per-provider, outside the core runtime).finalinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selfLink
→ TfRef<
String> -
Reference to
self_linkattribute (HTTPS API path). The canonical reference a downstreamgoogle_compute_url_mapuses to bind a path rule to this bucket.no setter - terraformType → String
-
Terraform resource type, e.g.
google_pubsub_topic.finalinherited - tfAddress → String
-
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited