Stay organized with collections
Save and categorize content based on your preferences.
This page describes how to configure Service Extensions plugins in
Media CDN routes.
You can use Media CDN with Service Extensions
to add custom code to the request-response processing path. Such customization
unlocks a wide variety of lightweight use cases.
WASM_ACTION: the ID or the fully qualified name
of the Wasm action
WASM_PLUGIN: the name of the plugin to which you
want to attach the action
EVENT: the portion of the payload to be processed
by the plugin as indicated by either or both of these values:
request-headers or response-headers. If not specified, both
headers are processed.
It might take some time for a Wasm action to be created.
Attach a plugin to a route
To attach a plugin in a Media CDN route, follow these steps:
It might take some time for the new plugin to be distributed across all
locations. The time might vary across locations because the plugin isn't
delivered to all locations simultaneously.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to configure Service Extensions plugins in\nMedia CDN routes.\n\nYou can use Media CDN with Service Extensions\nto add custom code to the request-response processing path. Such customization\nunlocks a wide variety of lightweight use cases.\n\nFor more information, see\n[Media CDN extensions overview](/service-extensions/docs/plugins-overview).\n\nBefore you begin\n\n1. [Create a Media CDN origin](/media-cdn/docs/quickstart#create-origin)\n2. [Create a Media CDN service](/media-cdn/docs/quickstart#create-service)\n3. [Create a plugin by using Service Extensions](/service-extensions/docs/create-plugin)\n\n| **Note:** Service Extensions plugins run after all other configurable features of Media CDN have run.\n\nCreate a Wasm action for a plugin\n\nWhen creating a Wasm action, you can't use a plugin that's already in use in a\nCloud Load Balancing extension.\n\nCreate a Wasm action for your Service Extensions plugin by running the\n[`gcloud alpha service-extensions wasm-actions create` command](/sdk/gcloud/reference/alpha/service-extensions/wasm-actions/create): \n\n```\ngcloud alpha service-extensions wasm-actions create WASM_ACTION \\\n --wasm-plugin=WASM_PLUGIN \\\n --supported-events=[EVENT,...]\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eWASM_ACTION\u003c/var\u003e: the ID or the fully qualified name of the Wasm action\n- \u003cvar translate=\"no\"\u003eWASM_PLUGIN\u003c/var\u003e: the name of the plugin to which you want to attach the action\n- \u003cvar translate=\"no\"\u003eEVENT\u003c/var\u003e: the portion of the payload to be processed by the plugin as indicated by either or both of these values: `request-headers` or `response-headers`. If not specified, both headers are processed.\n\nIt might take some time for a Wasm action to be created.\n\nAttach a plugin to a route\n\nTo attach a plugin in a Media CDN route, follow these steps:\n\n1. To export the current configuration of your service to a YAML file, run\n the [`gcloud edge-cache services export` command](/sdk/gcloud/reference/edge-cache/services/export):\n\n gcloud edge-cache services export \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSERVICE_NAME\u003c/span\u003e\u003c/var\u003e \\\n --destination=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eFILENAME\u003c/span\u003e\u003c/var\u003e.yaml\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e: the name of the Media CDN service\n - \u003cvar translate=\"no\"\u003eFILENAME\u003c/var\u003e: the name of the YAML file\n2. Use a text editor to edit the YAML file.\n\n3. Update the routes in the file to add the `wasmAction` header as shown in\n the following example:\n\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eSERVICE_NAME\u003c/span\u003e\u003c/var\u003e\n routing:\n hostRules:\n - hosts:\n - \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDOMAIN_NAME\u003c/span\u003e\u003cspan class=\"devsite-syntax-w\"\u003e \u003c/span\u003e\u003c/var\u003e\n pathMatcher: routes\n pathMatchers:\n - name: routes\n routeRules:\n - priority: '1'\n description: Route 1\n matchRules:\n - prefixMatch: /plugins\n origin: projects/\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e/locations/global/edgeCacheOrigins/\u003cvar translate=\"no\"\u003eORIGIN_NAME\u003c/var\u003e\n routeAction:\n wasmAction: projects/\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e/locations/global/wasmActions/\u003cvar translate=\"no\"\u003eWASM_ACTION\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSERVICE_NAME\u003c/var\u003e: the name of the Media CDN service\n - \u003cvar translate=\"no\"\u003eDOMAIN_NAME\u003c/var\u003e: the domain of the Media CDN service\n - \u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e: the [project number](/resource-manager/docs/creating-managing-projects#identifying_projects)\n - \u003cvar translate=\"no\"\u003eORIGIN_NAME\u003c/var\u003e: the origin for the content\n - \u003cvar translate=\"no\"\u003eWASM_ACTION\u003c/var\u003e: the Service Extensions Wasm action\n4. Save the YAML file.\n\n5. Run the [`gcloud edge-cache services import` command](/sdk/gcloud/reference/edge-cache/services/import):\n\n gcloud edge-cache services import \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-nn\"\u003eSERVICE_NAME\u003c/span\u003e\u003c/var\u003e \\\n --source=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eFILENAME\u003c/span\u003e\u003c/var\u003e.yaml\n\nIt might take some time for the new plugin to be distributed across all\nlocations. The time might vary across locations because the plugin isn't\ndelivered to all locations simultaneously.\n\nWhat's next\n\n- [View log messages for plugins](/service-extensions/docs/view-media-cdn-plugin-log-messages)\n- [Monitor plugins](/service-extensions/docs/monitor-media-cdn-plugins)"]]