Skip to content

Zero Trust Tunnels Terraform documentation is wrong is various ways #21057

@gregbrant2

Description

@gregbrant2

Existing documentation URL(s)

What changes are you suggesting?

The example for the cloudflare_zero_trust_tunnel_cloudflared_config has invalid syntax. I believe

resource "cloudflare_zero_trust_tunnel_cloudflared_config" "auto_tunnel" {
  tunnel_id = cloudflare_zero_trust_tunnel_cloudflared.auto_tunnel.id
  account_id = var.cloudflare_account_id
  config {
   ingress_rule {
     hostname = "${cloudflare_record.http_app.hostname}"
     ...
     }
   }
   ingress_rule {
     service  = "http_status:404"
   }
  }
}

should be

resource "cloudflare_zero_trust_tunnel_cloudflared_config" "auto_tunnel" {
  tunnel_id = cloudflare_zero_trust_tunnel_cloudflared.auto_tunnel.id
  account_id = var.cloudflare_account_id
  config = {
   ingress_rule =[ {
     hostname = "${cloudflare_record.http_app.hostname}"
     ...
   }, 
   ingress_rule = {
     service  = "http_status:404"
   }]
  }
}

As is, it gives the error

Error: Unsupported block type
│
│   on templates.tf line 200, in resource "cloudflare_zero_trust_tunnel_cloudflared_config" "auto_tunnel":
│  200:   config {
│
│ Blocks of type "config" are not expected here. Did you mean to define argument "config"? If so, use the equals sign to assign it a
│ value.

Your terraform documentation is littered with this kind of syntax error.

Once you fix this so the syntax is happy there is a further issue which I believe is a bug in the provider it's self whereby when you terraform apply the apply fails despite the terraform plan succeeding:

╷
│ Error: failed to make http request
│
│   with cloudflare_zero_trust_tunnel_cloudflared_config.gregbrant_com,
│   on templates.tf line 197, in resource "cloudflare_zero_trust_tunnel_cloudflared_config" "auto_tunnel":
│  197: resource "cloudflare_zero_trust_tunnel_cloudflared_config" "auto_tunnel" {
│
│ PUT
│ "https://api.cloudflare.com/client/v4/accounts/<acct_id>/cfd_tunnel/<tunnel_id>/configurations":
│ 400 Bad Request {"success":false,"errors":[{"code":1056,"message":"Bad Configuration: Validation failed: The config file doesn't
│ contain any ingress rules\n"}],"messages":[],"result":null}
╵

Additional information

Using v5.2.0

$ terraform version
Terraform v1.11.0
on linux_amd64
+ provider registry.terraform.io/ansible/ansible v1.3.0
+ provider registry.terraform.io/bpg/proxmox v0.73.2
+ provider registry.terraform.io/cloudflare/cloudflare v5.2.0
+ provider registry.terraform.io/hashicorp/local v2.5.2
+ provider registry.terraform.io/hashicorp/random v3.7.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions