This page describes how to configure Media CDN edge extensions
(CdnEdgeExtension) to attach WebAssembly (Wasm) plugins to
Media CDN Edge Cache Services
(EdgeCacheService).
A CdnEdgeExtension resource attaches directly to an EdgeCacheService
deployment and runs one or more ordered extension chains (extensionChains).
Each extension chain is matched by using Common Expression Language (CEL)
expressions and can contain a maximum of two chained WasmPlugin resources.
For more information, see Media CDN extensions overview.
Before you begin
- Create a Media CDN origin
- Create a Media CDN service
When configuring a
CdnEdgeExtensionresource, consider that Media CDN edge extensions run before most Media CDN features, including route matching and cache lookup. This lets a plugin rewrite headers or URLs to influence HTTP routing. However, plugin code can't inspect custom headers that Media CDN route rules add or built-in features. To access client and connection properties, such as client region, IP address, or TLS parameters, configure forward attributes.
Set up the Media CDN edge extension
To configure a CdnEdgeExtension resource and attach plugins to an
EdgeCacheService deployment, do the following:
Define the
CdnEdgeExtensionresource in a YAML file.The following example invokes
WASM_PLUGINto process both request and response headers when you send a request tomedia.example.com.Note: The
failOpen: falsesetting returns an HTTP500error code if the plugin fails or times out.cat >cdn-edge-extension.yaml <<EOF edgeCacheServices: - projects/PROJECT_ID/locations/global/edgeCacheServices/SERVICE_NAME extensionChains: - name: "edge-plugin-chain" matchCondition: celExpression: 'request.host == "media.example.com"' extensions: - name: "auth-and-header-plugin" service: projects/PROJECT_ID/locations/global/wasmPlugins/WASM_PLUGIN failOpen: false supportedEvents: - REQUEST_HEADERS - RESPONSE_HEADERS forwardAttributes: - request.method - request.host - request.path - source.client_region EOFReplace the following:
PROJECT_ID: ID of your Google Cloud projectSERVICE_NAME: name of the targetMedia CDNservice (EdgeCacheService)WASM_PLUGIN: name of your plugin, such asmy-wasm-plugin-resource
For more information about the fields in the YAML file, see ExtensionChain in the API documentation.
Use the
gcloud beta service-extensions cdn-edge-extensions importcommand to import theCdnEdgeExtensionresource:gcloud beta service-extensions cdn-edge-extensions import cdn-edge-ext \ --source=cdn-edge-extension.yaml \ --location=global
Note: It might take some time for the new plugin configuration to be distributed across all locations.
Limitations
- You can attach only one edge extension to an
EdgeCacheServicedeployment. - An edge extension chain can contain a maximum of two plugins.
- Media CDN edge extensions support
REQUEST_HEADERSandRESPONSE_HEADERSevents. These extensions don't support HTTP body or trailer processing. - Media CDN edge extensions let you use only one regular expression for each CEL expression.
- Names of extension chains and extensions must conform to RFC-1034. Under this specification, names can contain up to 63 lowercase alphanumeric characters or hyphens, must start with a letter, and must end with a letter or number.
For more information about resource limits, see Quotas and limits.