Provision secrets from the command line
Hello.
I'd like to be able to provision secrets on Cloudflare conveniently. I'd like to do
npx wrangler secret put <KEY>
for example and for Wrangler to get the key from .dev.vars
? I don't want to paste the key into the keyboard or type it in.
How do you solve this workflow problem? Or maybe I'm missing something?
Thanks3 Replies
You could use https://github.com/cloudflare/wrangler-action if you're deploying with GitHub and manage all your secrets that way.
GitHub
GitHub - cloudflare/wrangler-action: 🧙♀️ easily deploy cloudflare ...
🧙♀️ easily deploy cloudflare workers applications using wrangler and github actions - cloudflare/wrangler-action
How do you deploy secrets? I tried using the UI instead of the command line but when I tried to deploy code, Wrangler started giving warnings saying that I used the UI to deploy the project (by deploying secrets) and that I will override the config/code/... if I deploy using the command line.
This is a problem that caused us drift between the code and the deployed worker.
In other words, on the one hand its hard to deploy secrets using the command line but on the other hand when you use the UI to deploy secrets wrangler start giving errors and warnings when you want to deploy your code. It's a catch 22.
You generally want to use one or the other - wrangler, or UI. If you use a mixture, you're going to cause issues and create situations where you get mismatching data, etc.
I use
wrangler-action
for most of my Workers - that way I can push to GitHub, manage secrets there, and then have Actions publish my worker with all needed secrets.