Skip to content

Instantly share code, notes, and snippets.

@ep4sh
Created October 2, 2020 11:30
Show Gist options
  • Save ep4sh/b2c528997ea771920f0da735c23cb2ca to your computer and use it in GitHub Desktop.
Save ep4sh/b2c528997ea771920f0da735c23cb2ca to your computer and use it in GitHub Desktop.
Cloudflare HTTP 403 when specific plan exists.

Without plan option:

$ cat main.tf 
resource "cloudflare_zone" "qa" {
  zone = var.cloudflare_zone_name
}


$ terraform apply --var-file=variables/qa_vars.tf  
Acquiring state lock. This may take a few moments...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # cloudflare_zone.qa will be created
  + resource "cloudflare_zone" "qa" {
      + id                  = (known after apply)
      + meta                = (known after apply)
      + name_servers        = (known after apply)
      + plan                = (known after apply)
      + status              = (known after apply)
      + type                = "full"
      + vanity_name_servers = (known after apply)
      + verification_key    = (known after apply)
      + zone                = "qa.super.host"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

cloudflare_zone.qa: Creating...
cloudflare_zone.qa: Creation complete after 4s [id=805f9d4ca667c6878e4d03634fa29987]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
Releasing state lock. This may take a few moments...

If there is a specific plan - zone resource fails:

$ cat main.tf                                      
resource "cloudflare_zone" "qa" {
  zone = var.cloudflare_zone_name
  plan = "free"
}

terraform apply --var-file=variables/qa_vars.tf  
Acquiring state lock. This may take a few moments...

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # cloudflare_zone.qa will be created
  + resource "cloudflare_zone" "qa" {
      + id                  = (known after apply)
      + meta                = (known after apply)
      + name_servers        = (known after apply)
      + plan                = "free"
      + status              = (known after apply)
      + type                = "full"
      + vanity_name_servers = (known after apply)
      + verification_key    = (known after apply)
      + zone                = "qa.super.host"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

cloudflare_zone.qa: Creating...

Error: Error setting plan free for zone "805f9d4ca667c6878e4d03634fa29987": error from makeRequest: HTTP status 403: Authentication error

  on main.tf line 1, in resource "cloudflare_zone" "qa":
   1: resource "cloudflare_zone" "qa" {


Releasing state lock. This may take a few moments...
@eumoh1601
Copy link

hi where u ever able to resolve this issue

@ep4sh
Copy link
Author

ep4sh commented May 28, 2021

Hi @eumoh1601 - please check your security settings (it might be you're required for additional permissions in Cloudflare like "Account management" and generate an appropriate token - this helped me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment