Skip to content

cloudflared tunnel cred-file <TUNNEL_NAME> option #603

@firecow

Description

@firecow

Describe the feature you'd like
I would like an cloudflared tunnel cred-file <TUNNEL_NAME> option

Additional context
Cego A/S is migrating away from legacy argo tunnels to named tunnels.
It would ease our transition if we could retrieve an already generated credential file via cloudflared tunnel cli

Here is our use case in Gitlab CI/CD YML format

---
# .gitlab-ci.yml

deploy:
  variables:
     TUNNEL_CERTIFICATE_FILE: # Found in our Gitlab CI/CD variables. (Cert.pem from cloudflared login)
     TUNNEL_NAME: somesub.cego.dk
  script:    
    - TUNNEL_ORIGIN_CERT="${TUNNEL_CERTIFICATE_FILE}"
    - | 
      cloudflared tunnel cred-file "${TUNNEL_NAME}" --output .cloudflared || 
        (cloudflared tunnel create "${TUNNEL_NAME}" &&
          cloudflared tunnel route dns "${TUNNEL_NAME}" "${TUNNEL_NAME}")
    - TUNNEL_CRED_FILE=$(find .cloudflared -name '*.json')
    - TUNNEL_UUID=$(grep -oP '"TunnelID":"\K(.*)(?=")' ${TUNNEL_CRED_FILE})
    - docker stack deploy
--- 
# docker-compose.yml

configs:
  cloudflared-cred-file:
    file: ${TUNNEL_CRED_FILE}

services:

  cloudflared:
    image: cloudflare/cloudflared:2022.3.1
    command: tunnel run ${TUNNEL_UUID}
    configs:
      - source: cloudflared-cred-file
        target: /etc/cloudflared/${TUNNEL_UUID}.json
    environment:
      TUNNEL_URL: http://${STACK_NAME}_web

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs clarificationUnable to move forward on the reported issueType: Feature RequestA big idea that would be split into smaller pieces

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions