Terraform Configuration for Cloudflare Workers

This Terraform configuration sets up Cloudflare Workers for a given domain. It includes configurations for providers, resources, and data sources.

Files Overview

  1. backend.tf: Contains provider and backend configurations.
  2. cloudflare.tf: Defines Cloudflare Worker Script, routes, and the local file dependencies.
  3. data.tf: Provides data sources used in the configuration.
  4. variables.tf: Lists the variables required for the configuration.

Note:

  • This code is setup with a null resource that is able to run code directly on Terraform cloud without needing a CI job for npm. (However that can be toggled off and be run in a standard pipeline)

Requirements

Name Version
cloudflare 4.6.0

Providers

Name Version
cloudflare 4.6.0
local n/a
null n/a

Modules

No modules.

Resources

Name Type
cloudflare_worker_route.worker-routes resource
cloudflare_worker_script.worker resource
null_resource.webpack resource
cloudflare_zone.zone data source
local_file.worker data source

Inputs

Name Description Type Default Required
cloudflare_account_id n/a any n/a yes
cloudflare_api_key Cloudflare any n/a yes
enable_webpack_bundle Toggle to determine if webpack bundling should be done bool false no
env n/a any n/a yes

Outputs

No outputs.