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

cloudflared tunnel cred-file <TUNNEL_NAME> option #603

Closed
firecow opened this issue Mar 18, 2022 · 10 comments
Closed

cloudflared tunnel cred-file <TUNNEL_NAME> option #603

firecow opened this issue Mar 18, 2022 · 10 comments
Labels
Needs clarification Unable to move forward on the reported issue Type: Feature Request A big idea that would be split into smaller pieces

Comments

@firecow
Copy link
Contributor

firecow commented Mar 18, 2022

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
@firecow firecow added Needs clarification Unable to move forward on the reported issue Type: Feature Request A big idea that would be split into smaller pieces labels Mar 18, 2022
@nmldiegues
Copy link
Contributor

Hello @firecow ,

Can you clarify what you would envision cloudflared tunnel cred-file <TUNNEL_NAME> to do?
What's the side-effect/output of such command?

I think there's a chance you are confusing the cert.pem used to manage Tunnels (see https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-useful-terms/#certpem) with the JSON credentials file used to run the Tunnel (see https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-useful-terms/#credentials-file)

@firecow
Copy link
Contributor Author

firecow commented Mar 18, 2022

This is what I envision the command should do

cloudflared tunnel cred-file <TUNNEL_NAME> # puts 3218372198372198321.json into .cloudflared folder
cat .cloudflared/3218372198372198321.json
{
  "AccountTag":"<CEGOACCOUNTAG>",
  "TunnelSecret":"<REDACTED>",
  "TunnelID":"<thetunnelid>"
}

@nmldiegues
Copy link
Contributor

Oh I see. You'd like to be able to retrieve the secret and re-create the credentials JSON file for an already created Tunnel, with the cert.pem to authenticate that.

That was not possible until recently because we would not store the secret on our end. This has changed in fact, as we now store it (securely).
So this is doable.

@firecow
Copy link
Contributor Author

firecow commented Mar 18, 2022

Yeah, I saw the "token" addition on api.cloudflare.com under the tunnels section, and thought this feature would be possible.

Reusing our exiting cert.pem secret handling to fetch or create tunnel cred files on demand during deployment would really ease our transition away from legacy tunnel.

👍

@firecow firecow changed the title cloudflared tunnel cred-file <TUNNEL_NAME> optionn cloudflared tunnel cred-file <TUNNEL_NAME> option Mar 18, 2022
@abelinkinbio
Copy link
Contributor

Thanks for submitting this FR. We're planning to discuss this a little more internally and see if we can get this into our next release.

@firecow
Copy link
Contributor Author

firecow commented Mar 20, 2022

@abelinkinbio That would be awesome, then I'll have our 2 miliion tunnels (kidding!) away from legacy in no time 😄

@nmldiegues
Copy link
Contributor

This is likely going to be available in the next release. Stay tuned.

@firecow
Copy link
Contributor Author

firecow commented Mar 26, 2022

Thanks for this addition, I'm closing this issue.

@hadifarnoud
Copy link

cloudflared tunnel cred-file command no longer exists

@tmonck
Copy link

tmonck commented Jun 7, 2024

#645 (comment) shows you how to get the creds file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs clarification Unable to move forward on the reported issue Type: Feature Request A big idea that would be split into smaller pieces
Projects
None yet
Development

No branches or pull requests

5 participants