cf-terraforming icon indicating copy to clipboard operation
cf-terraforming copied to clipboard

Generating cloudflare_tunnel uses the 'tunnel_token' for 'secret' field

Open Weshnaw opened this issue 2 years ago • 0 comments

Confirmation

  • [X] My issue isn't already found on the issue tracker.
  • [X] I have replicated my issue using the latest version of the library and it is still present.

cf-terraforming version

cf-terraforming v0.12.0

Expected outcome

I expect the output to be formatted such:

resource "cloudflare_tunnel" "terraform_managed_resource_tunnel_id" {
  account_id = "account_id"
  name       = "tunnel_name"
  secret     = "tunnel_secret"
}

Actual outcome

what is actually output

resource "cloudflare_tunnel" "terraform_managed_resource_tunnel_id" {
  account_id = "account_id"
  name       = "tunnel_name"
  secret     = "tunnel_token"
}

NOTE: that we can run the "tunnel_token" through base64 -d to show that it's the token and not just a base64 looking secret

echo "tunnel_token" | base64 -d {"a":"account_id","t":"tunnel_id","s":"actual_tunnel_secret"}

Steps to reproduce

  1. have an existing cloudflare tunnel
  2. add CLOUDFLARE_API_TOKEN env variable with edit permissions to cloudflare tunnels
  3. create minimal cloudflare.tf
  4. run terraform init
  5. run cf-terraforming generate --resource-type "cloudflare_tunnel" -a account_id
cloudflare.tf
terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 4.0"
    }
  }
}

provider "cloudflare" {
}

References

No response

Weshnaw avatar Jun 05 '23 23:06 Weshnaw