Zone creation with Terraform Cloud not working

Hello everyone :wave:

I’m trying to create a zone with Terraform Cloud, but every time I get the same result:

Terraform v0.14.3
Configuring remote state backend...
Initializing Terraform configuration...

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

I’m sure my account doesn’t have the zone I’m trying to create. I tried to use both a combination of email and global API key and API token, although I think this is not the case, otherwise I would receive authorization errors.

I have main.tf and variables.tf files in my repository. Here is main.tf:

terraform {
  required_providers {
    cloudflare = {
      source = "cloudflare/cloudflare"
      version = "2.14.0"
    }
  }
}

provider "cloudflare" {
  email = var.cloudflare_email
  api_key = var.cloudflare_api_key
}

resource "cloudflare_zone" "example" {
  zone = "example3.com"
  plan = "free"
}

And here is variables.tf:

variable "cloudflare_email" {
  type = string
}

variable "cloudflare_api_key" {
  type = string
}

I use Environment Variables in Terraform Cloud.

Could you please tell me what exactly I’m doing wrong?

Hmm :thinking: The main.tf and variables.tf files were placed in a directory named dns in the repository, and after I moved them to the root I got a new message in Terraform Cloud backend:

Terraform v0.14.3
Configuring remote state backend...
Initializing Terraform configuration...

Error: No value for required variable

  on variables.tf line 1:
   1: variable "cloudflare_email" {

The root module input variable "cloudflare_email" is not set, and has no
default value. Use a -var or -var-file command line argument to provide a
value for this variable.


Error: No value for required variable

  on variables.tf line 5:
   5: variable "cloudflare_api_key" {

The root module input variable "cloudflare_api_key" is not set, and has no
default value. Use a -var or -var-file command line argument to provide a
value for this variable.

At the same time, the variables themselves are present in the Terraform Cloud backend:

Not sure if I should further seek help with Terraform support…

If the environment variables already have values in it, then I guess you need to seek help from Terraform.

@erictung you’re right, I tried the other provider and got the same result. Maybe this reference will help someone in the future.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.