Terraform token invalid

What is the name of the domain?

jcreyesb.xyz

What is the error message?

Provided Tunnel token is not valid.

What is the issue you’re encountering

When i deployed tunnel using terraform. The token is not valid to connect.

What steps have you taken to resolve the issue?

My current terraform config is:
resource “random_password” “tunnel_password” {
length = 64
}

resource “cloudflare_zero_trust_tunnel_cloudflared” “home” {
account_id = var.account_id
name = “home”
tunnel_secret = base64sha256(random_password.tunnel_password.result)
}
I tried with “random_string” before, but i got the same error. So I cannot solve this error.

Which documentation have you used to deploy? :thinking:

Would below one work for your case (adopt to your variable names)? :thinking:

resource "random_password" "tunnel_token" {
  length = 64
}
resource "cloudflare_tunnel" "home" {
  account_id = var.cloudflare_account_id
  name       = "home"
  secret     = base64sha256(random_password.tunnel_token.result)
}

output "tunnel_token" {
  description = "Cloudflare Tunnel Token"
  value = cloudflare_tunnel.home.tunnel_token
  sensitive   = true
}

Thanks, @fritex. I finally got it! I need to base64 encode the JSON file. This file provides the account, tunnel secret, and tunnel ID.

I can use a configuration file like this
tunnel: Tunnel_Id
credentials-file: file.json
warp-routing:
enabled: true

and the command “cloudflared tunnel --config /path/your-config-file.yml run ”
Or use “sudo cloudflared service install Base64_file_encode”

1 Like

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