Skip to content

Deploying a tunnel with terraform and connecting manually #17398

@povilasb

Description

@povilasb

Existing documentation URL(s)

What changes are you suggesting?

There's the 2 above mentioned documents on how to create the Cloudflare tunnels in different ways:

  1. manually via the dashboard,
  2. with terraform.

I was dealing with a use case that is a combo of both:

  1. created a tunnel with terraform,
  2. and manually ran a Mac OS connector with cloudflared tunnel run

None of the docs cover this use case and quite some time was spent on how to make it work.
Which roughly resulted in

  1. describe the tunnel in Terraform based on: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/deploy-tunnels/deployment-guides/terraform/
  2. but now I can't use something like
  // Configures the VM to run a startup script that takes in the Terraform variables.
  metadata_startup_script = templatefile("./install-tunnel.tpl",
    {
      tunnel_token = cloudflare_tunnel.auto_tunnel.tunnel_token
    })
    
  cloudflared:
    image: cloudflare/cloudflared:latest
    restart: always
    container_name: cloudflared
    command: tunnel run --token ${tunnel_token}

since my Mac OS machine is not managed by Terraform.

  1. Then on Mac OS I had to do:
cloudflared login
cloudflared tunnel token --cred-file ~/.cloudflared/$TUNNEL_ID.json $TUNNEL_ID
cloudflared tunnel run

Quite simple but this command took me some time to find: cloudflared tunnel token --cred-file.

Do you think it would be worth expanding the docs?

Additional information

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions