-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the solution
Problem
Currently, there is no way to let wrangler know about secrets so that it can include them in the automatically generated type definitions (wrangler types command).
Tried solutions
I can specify regular env vars in [vars] but when doing so with a secret, it becomes problematic later. For example, trying to set such var's value with wrangler secret put after deployment results in an error saying that the variable is already set and I have to delete all of those encrypted variables first.
I'm pretty sure this is not the intended way of doing things and prevents wrangler.toml from being the full source-of-truth which is its purpose (as documented). Cloudflare's Web UI even tells you to update the wrangler.toml file after updating the env vars with encrypted values, though it just suggests adding <empty textbox> (I had 4 secrets so it actually was a textbox with 4 newlines 😄) to the wrangler.toml file.
Suggested solution
I think that the wrangler.toml should probably get a new secrets array specifically for specifying variables that are encrypted. Technically, it could make sense to allow specifying whether the variable should be encrypted directly in the [vars] table but this would likely be problematic as variable values are not limited to text values (see docs).
Additional context
I asked about this earlier this week on Cloudflare Developers Discord and was asked (by @ Skye-31) to make an issue:
https://discord.com/channels/595317990191398933/799437470004412476/1234495956259704984