A default config for new cloudflare domains.
I recommend forking this repo and changing the config to your liking.
Note: you will also need to install the terraform cli. This does not apply to windows users. The terraform windows exe is included to simplify the install.
git clone https://github.com/AspieSoft/TerraformCloudflareConfig.git
- Generate a cloudflare api token with access to your cloudflare config. You will need to include the following zone edit permissions:
- Config Rules
- Cache Rules
- Origin Rules
- Zone Settings
- SSL and Certificates
- Set the key to an environment variable with the name
CLOUDFLARE_API_TOKEN
(in linuxecho 'export CLOUDFLARE_API_TOKEN="<Insert Cloudflare API Token>"' >> .zshrc
) or you can add it to a local file next to your cloudflare.tf file namedcloudflare_api_token.key
. - run
TerraformCloudflareConfig/run
, you may be prompted to enter the Zone ID for the cloudflare domain you want to change. (Note: add the flag-y
to autoyes confirmation prompts when possible)
Add a file named zone.list
and add multiple zone id's (one per line) to automatically configure multiple domains with the same settings. (Note: this will enable the autoyes feature)