slauger/hcloud-okd4

missing variable CLOUDFLARE_API_TOKEN

missteek opened this issue · 2 comments

Hello there,

Great guide only missing important info about the API token creation, just spent a good 24 hours trying to get this to work - hope this helps others avoid the same pain!

  1. create API token following the instructions from here:
  1. From the Hashicorp guide:
  • Create an environment variable named CLOUDFLARE_API_TOKEN and set it to your Cloudflare API token.
    $ export CLOUDFLARE_API_TOKEN=Oo-bF...
  1. On the container the following variables are required:
export TF_VAR_dns_domain=example.com
export TF_VAR_dns_zone_id=myzoneid
export HCLOUD_TOKEN=my hetzner cloud_token
export CLOUDFLARE_EMAIL=user@example.com
export CLOUDFLARE_API_KEY=cloudflare GLOBAL api key
  1. This addittional variable is required:
export CLOUDFLARE_API_TOKEN=Oo-bF...
  1. If you don't export the CLOUDFLARE_API_TOKEN variable, the Cloudflare API does not create DNS records and you get the following when running make infrastructure BOOTSTRAP=true
Error: failed to create DNS record: error from makeRequest: HTTP status 403: Authentication error
 
   with cloudflare_record.dns_a_apps_wc,
   on dns.tf line 34, in resource "cloudflare_record" "dns_a_apps_wc":
   34: resource "cloudflare_record" "dns_a_apps_wc" {

Thank you

Thank you for the feedback! Yes, the API Tokens for the CloudFlare API are a bit confusing - especially the global API key. I added a link to this issue in the README.md for new users.

The general documentation for the Cloudflare provider can be found here btw:

https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs#api_token

Thanks for the info and update to the README.