Reputation: 3760
I'm trying to follow terraform documentation, but for some reason I'm getting error while trying to authenticate with my Cloudlfare account from within terraform (with terragrunt).
So my config is:
locals {
cloudflare_api_token = get_env("CLOUDFLARE_API_TOKEN")
cloudflare_email = get_env("CLOUDFLARE_EMAIL")
}
terraform {
source = "my source dir"
}
generate "versions" {
path = "versions.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
}
}
EOF
}
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
provider "cloudflare" {
email = "${local.cloudflare_email}"
api_token = "${local.cloudflare_api_token}"
}
EOF
}
Now, the error is:
"email": all of `api_key,email` must be specified
I'm a bit confused as I think I actually don't need to use api_key
if I'm using api_token
. Also api_key
seems to be deprecated.
Btw, terraform configs are created correctly (from terragrunt configs).
How can I authenticate?
Upvotes: 0
Views: 1180
Reputation: 61
email or variable CLOUDFLARE_EMAIL required when using api_key. Conflicts with api_token.
Upvotes: 0
Reputation: 28652
Just remove provider.email
( your email = "${local.cloudflare_email}"
), since you don't need it when using an API token.
From v3.19.0 introduces breaking change around configuration
you only need email when defining api_key.
I would call this a bug 🐛 in terraform-provider-cloudflare
, in that it gives you a bad error message.
Upvotes: 2