Configure Snippets using Terraform
You can create Snippets using the Terraform Cloudflare provider ↗.
To get started with Terraform for Cloudflare configuration, refer to Terraform: Get started.
The following example Terraform configuration creates a snippet and an associated snippet rule that defines when the snippet code will run. The snippet code is loaded from the file1.js
file in your machine.
The name of a snippet can only contain the characters a-z
, 0-9
, and _
(underscore). The name must be unique in the context of the zone.
All snippet_name
values in the cloudflare_snippet_rules
resource must match the names of existing snippets.
Refer to the Terraform Cloudflare provider documentation ↗ for more information on the cloudflare_snippet
and cloudflare_snippet_rules
resources.