Skip to content

googleNetworkServicesEdgeCacheOrigin

EdgeCacheOrigin represents a HTTP-reachable backend for an EdgeCacheService.

Example Usage - Network Services Edge Cache Origin Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.networkServicesEdgeCacheOrigin.NetworkServicesEdgeCacheOrigin(
  this,
  "default",
  {
    description: "The default bucket for media edge test",
    name: "my-origin",
    origin_address: "gs://media-edge-default",
  }
);

Example Usage - Network Services Edge Cache Origin Advanced

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleNetworkServicesEdgeCacheOriginFallback =
  new google.networkServicesEdgeCacheOrigin.NetworkServicesEdgeCacheOrigin(
    this,
    "fallback",
    {
      description: "The default bucket for media edge test",
      max_attempts: 3,
      name: "my-fallback",
      origin_address: "fallback.example.com",
      origin_override_action: [
        {
          header_action: [
            {
              request_headers_to_add: [
                {
                  header_name: "x-header",
                  header_value: "value",
                  replace: true,
                },
              ],
            },
          ],
          url_rewrite: [
            {
              host_rewrite: "example.com",
            },
          ],
        },
      ],
      origin_redirect: [
        {
          redirect_conditions: [
            "MOVED_PERMANENTLY",
            "FOUND",
            "SEE_OTHER",
            "TEMPORARY_REDIRECT",
            "PERMANENT_REDIRECT",
          ],
        },
      ],
      port: 80,
      protocol: "HTTP",
      retry_conditions: [
        "CONNECT_FAILURE",
        "NOT_FOUND",
        "HTTP_5XX",
        "FORBIDDEN",
      ],
      timeout: [
        {
          connect_timeout: "10s",
          max_attempts_timeout: "20s",
          read_timeout: "5s",
          response_timeout: "60s",
        },
      ],
    }
  );
new google.networkServicesEdgeCacheOrigin.NetworkServicesEdgeCacheOrigin(
  this,
  "default",
  {
    description: "The default bucket for media edge test",
    failover_origin: googleNetworkServicesEdgeCacheOriginFallback.id,
    labels: [
      {
        a: "b",
      },
    ],
    max_attempts: 2,
    name: "my-origin",
    origin_address: "gs://media-edge-default",
    timeout: [
      {
        connect_timeout: "10s",
      },
    ],
  }
);

Example Usage - Network Services Edge Cache Origin V4auth

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleSecretManagerSecretSecretBasic =
  new google.secretManagerSecret.SecretManagerSecret(this, "secret-basic", {
    replication: [
      {
        automatic: true,
      },
    ],
    secret_id: "secret-name",
  });
const googleSecretManagerSecretVersionSecretVersionBasic =
  new google.secretManagerSecretVersion.SecretManagerSecretVersion(
    this,
    "secret-version-basic",
    {
      secret: googleSecretManagerSecretSecretBasic.id,
      secret_data: "secret-data",
    }
  );
new google.networkServicesEdgeCacheOrigin.NetworkServicesEdgeCacheOrigin(
  this,
  "default",
  {
    aws_v4_authentication: [
      {
        access_key_id: "ACCESSKEYID",
        origin_region: "auto",
        secret_access_key_version:
          googleSecretManagerSecretVersionSecretVersionBasic.id,
      },
    ],
    description: "The default bucket for V4 authentication",
    name: "my-origin",
    origin_address: "gs://media-edge-default",
  }
);

Argument Reference

The following arguments are supported:

  • originAddress - (Required) A fully qualified domain name (FQDN) or IP address reachable over the public Internet, or the address of a Google Cloud Storage bucket. This address will be used as the origin for cache requests - e.g. FQDN: media-backend.example.com, IPv4: 35.218.1.1, IPv6: 2607:f8b0:4012:809::200e, Cloud Storage: gs://bucketname When providing an FQDN (hostname), it must be publicly resolvable (e.g. via Google public DNS) and IP addresses must be publicly routable. It must not contain a protocol (e.g., https://) and it must not contain any slashes. If a Cloud Storage bucket is provided, it must be in the canonical "gs://bucketname" format. Other forms, such as "storage.googleapis.com", will be rejected.

  • name - (Required) Name of the resource; provided by the client when the resource is created. The name must be 1-64 characters long, and match the regular expression [a-zA-Z][a-zA-Z0-9_-]* which means the first character must be a letter, and all following characters must be a dash, underscore, letter or digit.


  • description - (Optional) A human-readable description of the resource.

  • labels - (Optional) Set of label tags associated with the EdgeCache resource.

  • protocol - (Optional) The protocol to use to connect to the configured origin. Defaults to HTTP2, and it is strongly recommended that users use HTTP2 for both security & performance. When using HTTP2 or HTTPS as the protocol, a valid, publicly-signed, unexpired TLS (SSL) certificate must be presented by the origin server. Possible values are http2, https, and http.

  • port - (Optional) The port to connect to the origin on. Defaults to port 443 for HTTP2 and HTTPS protocols, and port 80 for HTTP.

  • maxAttempts - (Optional) The maximum number of attempts to cache fill from this origin. Another attempt is made when a cache fill fails with one of the retryConditions. Once maxAttempts to this origin have failed the failoverOrigin will be used, if one is specified. That failoverOrigin may specify its own maxAttempts, retryConditions and failoverOrigin to control its own cache fill failures. The total number of allowed attempts to cache fill across this and failover origins is limited to four. The total time allowed for cache fill attempts across this and failover origins can be controlled with maxAttemptsTimeout. The last valid, non-retried response from all origins will be returned to the client. If no origin returns a valid response, an HTTP 502 will be returned to the client. Defaults to 1. Must be a value greater than 0 and less than 4.

  • failoverOrigin - (Optional) The Origin resource to try when the current origin cannot be reached. After maxAttempts is reached, the configured failoverOrigin will be used to fulfil the request. The value of timeout.maxAttemptsTimeout dictates the timeout across all origins. A reference to a Topic resource.

  • retryConditions - (Optional) Specifies one or more retry conditions for the configured origin. If the failure mode during a connection attempt to the origin matches the configured retryCondition(s), the origin request will be retried up to maxAttempts times. The failoverOrigin, if configured, will then be used to satisfy the request. The default retryCondition is "CONNECT_FAILURE". retryConditions apply to this origin, and not subsequent failoverOrigin(s), which may specify their own retryConditions and maxAttempts. Valid values are:

    • CONNECT_FAILURE: Retry on failures connecting to origins, for example due to connection timeouts.
    • HTTP_5XX: Retry if the origin responds with any 5xx response code, or if the origin does not respond at all, example: disconnects, reset, read timeout, connection failure, and refused streams.
    • GATEWAY_ERROR: Similar to 5xx, but only applies to response codes 502, 503 or 504.
    • RETRIABLE_4XX: Retry for retriable 4xx response codes, which include HTTP 409 (Conflict) and HTTP 429 (Too Many Requests)
    • NOT_FOUND: Retry if the origin returns a HTTP 404 (Not Found). This can be useful when generating video content, and the segment is not available yet.
    • FORBIDDEN: Retry if the origin returns a HTTP 403 (Forbidden). Each value may be one of connectFailure, http5Xx, gatewayError, retriable4Xx, notFound, and forbidden.
  • timeout - (Optional) The connection and HTTP timeout configuration for this origin. Structure is documented below.

  • awsV4Authentication - (Optional) Enable AWS Signature Version 4 origin authentication. Structure is documented below.

  • originOverrideAction - (Optional) The override actions, including url rewrites and header additions, for requests that use this origin. Structure is documented below.

  • originRedirect - (Optional) Follow redirects from this origin. Structure is documented below.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The timeout block supports:

  • connectTimeout - (Optional) The maximum duration to wait for a single origin connection to be established, including DNS lookup, TLS handshake and TCP/QUIC connection establishment. Defaults to 5 seconds. The timeout must be a value between 1s and 15s. The connectTimeout capped by the deadline set by the request's maxAttemptsTimeout. The last connection attempt may have a smaller connectTimeout in order to adhere to the overall maxAttemptsTimeout.

  • maxAttemptsTimeout - (Optional) The maximum time across all connection attempts to the origin, including failover origins, before returning an error to the client. A HTTP 504 will be returned if the timeout is reached before a response is returned. Defaults to 15 seconds. The timeout must be a value between 1s and 30s. If a failoverOrigin is specified, the maxAttemptsTimeout of the first configured origin sets the deadline for all connection attempts across all failoverOrigins.

  • responseTimeout - (Optional) The maximum duration to wait for the last byte of a response to arrive when reading from the HTTP connection/stream. Defaults to 30 seconds. The timeout must be a value between 1s and 120s. The responseTimeout starts after the connection has been established. This also applies to HTTP Chunked Transfer Encoding responses, and/or when an open-ended Range request is made to the origin. Origins that take longer to write additional bytes to the response than the configured responseTimeout will result in an error being returned to the client. If the response headers have already been written to the connection, the response will be truncated and logged.

  • readTimeout - (Optional) The maximum duration to wait between reads of a single HTTP connection/stream. Defaults to 15 seconds. The timeout must be a value between 1s and 30s. The readTimeout is capped by the responseTimeout. All reads of the HTTP connection/stream must be completed by the deadline set by the responseTimeout. If the response headers have already been written to the connection, the response will be truncated and logged.

The awsV4Authentication block supports:

  • accessKeyId - (Required) The access key ID your origin uses to identify the key.

  • secretAccessKeyVersion - (Required) The Secret Manager secret version of the secret access key used by your origin. This is the resource name of the secret version in the format projects/*/secrets/*/versions/* where the * values are replaced by the project, secret, and version you require.

  • originRegion - (Required) The name of the AWS region that your origin is in.

The originOverrideAction block supports:

  • urlRewrite - (Optional) The URL rewrite configuration for request that are handled by this origin. Structure is documented below.

  • headerAction - (Optional) The header actions, including adding and removing headers, for request handled by this origin. Structure is documented below.

The urlRewrite block supports:

  • hostRewrite - (Optional) Prior to forwarding the request to the selected origin, the request's host header is replaced with contents of the hostRewrite. This value must be between 1 and 255 characters.

The headerAction block supports:

  • requestHeadersToAdd - (Optional) Describes a header to add. You may add a maximum of 25 request headers. Structure is documented below.

The requestHeadersToAdd block supports:

  • headerName - (Required) The name of the header to add.

  • headerValue - (Required) The value of the header to add.

  • replace - (Optional) Whether to replace all existing headers with the same name. By default, added header values are appended to the response or request headers with the same field names. The added values are separated by commas. To overwrite existing values, set replace to true.

The originRedirect block supports:

  • redirectConditions - (Optional) The set of redirect response codes that the CDN follows. Values of RedirectConditions are accepted.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/locations/global/edgeCacheOrigins/{{name}}

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 60 minutes.
  • update - Default is 60 minutes.
  • delete - Default is 60 minutes.

Import

EdgeCacheOrigin can be imported using any of these accepted formats:

$ terraform import google_network_services_edge_cache_origin.default projects/{{project}}/locations/global/edgeCacheOrigins/{{name}}
$ terraform import google_network_services_edge_cache_origin.default {{project}}/{{name}}
$ terraform import google_network_services_edge_cache_origin.default {{name}}

User Project Overrides

This resource supports User Project Overrides.