Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent/weird behavior of cloudflare_zero_trust_tunnel_cloudflared_config, Authentication Error (10000) #4002

Closed
3 tasks done
OctavioCore opened this issue Sep 13, 2024 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@OctavioCore
Copy link

OctavioCore commented Sep 13, 2024

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v 1.9.4, Terraform v 1.9.5
Cloudflare Provider v 4.41.0

Affected resource(s)

  • cloudflare_zero_trust_tunnel_cloudflared_config
  • cloudflare_zero_trust_tunnel_cloudflared

Terraform configuration files

data "cloudflare_zone" "this" {
  name = local.cloudflare_config["root_zone_name"]
}

resource "cloudflare_zero_trust_tunnel_cloudflared" "this" {
  account_id = data.cloudflare_zone.this.account_id
  name       = local.cloudflare_config.zero_trust_config.private_access_url_prefix
  secret     = base64encode(random_password.cf_tunnel_token.result)
  config_src = "cloudflare"
}

resource "cloudflare_zero_trust_tunnel_cloudflared_config" "base_config" {
  account_id = data.cloudflare_zone.this.zone_id
  tunnel_id  = cloudflare_zero_trust_tunnel_cloudflared.this.id

  config {
    warp_routing {
      enabled = false
    }

    ingress_rule {
      hostname = "${local.cloudflare_config.zero_trust_config.private_access_url_prefix}.${local.cloudflare_config["root_zone_name"]}"
      service  = "ssh://127.0.0.1"
    }

    origin_request {
      bastion_mode             = false
      disable_chunked_encoding = false
      http2_origin             = false
      keep_alive_connections   = 0
      no_happy_eyeballs        = false
      no_tls_verify            = false
      proxy_port               = 0
    }

    ingress_rule {
      service = "http_status:404"
    }
  }
}

Link to debug output

https://gist.github.com/OctavioCore/821538eb1ccf4914c8ab63cdcfb33765

Panic output

│ Error: error creating / updating tunnel config "": Authentication error (10000)

│ with cloudflare_zero_trust_tunnel_cloudflared_config.base_config,
│ on cloudflare.tf line 69, in resource "cloudflare_zero_trust_tunnel_cloudflared_config" "base_config":
│ 69: resource "cloudflare_zero_trust_tunnel_cloudflared_config" "base_config" {

Expected output

Config adjusted successfully for the provisioned tunnel.

Actual output

The tunnel is provisioned succesfully, but the tunnel configuration resource apply fails with "Authentication error (10000)" regardless if it's being provisioned from scratch, or updated.

Steps to reproduce

  1. Use api token as your provider auth method
  2. Use attached code
  3. Run apply

Additional factoids

I've thought that this might be due to errors in Terraform code on my part, so I've imported the config "clicked out" in the UI, then ran a plan to figure out discrepancies. Import went fine, the following plan has succeeded and shown some discrepancies I've reconciled into the code.

After making those code changes, I ran apply action - but it failed at plan stage, with the Authentication Error (10000). I have destroyed the entire stack, ran apply again, and it fails with the Authentication Error (10000) as before.

I've checked the token used for authentication; It has all the necessary permissions to edit tunnels. I can also modify the config in the UI, so it's most probably not associated with permissions at all.

References

Perhaps it is linked to #3950 in some way/combines with this issue from the import part onwards?

@OctavioCore OctavioCore added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 13, 2024
Copy link
Contributor

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

Copy link
Contributor

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

@github-actions github-actions bot added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 13, 2024
@OctavioCore
Copy link
Author

OctavioCore commented Sep 16, 2024

Attached whatever I could find about the resources in question in the debug log section. I won't be able to provide the full debug log - the Cloudflare config is just a small part of a bigger module with multiple providers.

@OctavioCore
Copy link
Author

Nevermind, i've located the source of the issue, it was me all along ;)
There's a typo in the code, I've accidentally put zone_id in place of account_id - after fixing this goof, the config apply goes through. Closing this one, sorry for the mess!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

1 participant