Describe the solution
Problem Statement
Currently, there's no practical way to upload Worker code and environment variables/secrets together in a single atomic operation with wrangler versions upload. This creates challenges for complex deployment scenarios, particularly when coordinating multiple Workers.
Current Limitations
1. --var Flag Issues:
- Requires complex scripting to extract variables from
.env files
- Variables are stored as plain text, not as encrypted secrets
- Not suitable for sensitive data (API keys, tokens, etc.)
2. wrangler secret bulk Separation:
- Creates a separate version for secrets vs code
- Makes atomic deployments and rollbacks more complex
- Doesn't align with versioning workflow for coordinated deployments
Use Case: Atomic Multi-Worker Deployment
We deploy API and frontend Workers together using this workflow:
# Phase 1: Upload both workers (code only)
wrangler versions upload --name api-worker
wrangler versions upload --name frontend-worker
# Phase 2: Deploy both versions atomically
wrangler versions deploy <api-version-id>@100% --name api-worker
wrangler versions deploy <frontend-version-id>@100% --name frontend-worker
Problem: Environment variables using secrets must be managed separately, breaking atomicity and complicating rollbacks.
Current Workaround
We've implemented complex TypeScript scripts that:
- Parse
.env files
- Extract key-value pairs
- Pass them via multiple
--var arguments
- Hide sensitive values in logs
// Example of current complexity
const envVars = parseEnvFile('.env.production')
const args = ['versions', 'upload', '--var']
envVars.forEach(({ key, value }) => {
args.push(`${key}:${value}`) // Plain text, not encrypted
})
Proposed Solution
Option A: Environment File Support
wrangler versions upload --env-file .env.production
wrangler versions upload --env-file .env.staging --env staging
Option B: Secrets File Support
wrangler versions upload --secrets-file .secrets.production
Option C: Mixed Approach
wrangler versions upload --env-file .env.production --secrets-file .secrets.production
Benefits
- 🔒 Security: Secrets stored encrypted, not as plain text
- ⚡ Simplicity: No complex scripting required
- 🎯 Atomicity: Code + environment in single version
- 🔄 Rollbacks: Single version contains everything
- 📦 Consistency: Aligns with existing
.env ecosystem
Alternative Considerations
If file-based approach isn't feasible, consider:
Related Issues
This would greatly improve developer experience for:
- Multi-service deployments
- Environment parity
- CI/CD pipelines
- Blue-green deployments
Workaround Impact
Current workarounds require significant custom tooling and don't provide the security or atomicity that Cloudflare's versioning system otherwise enables.
Would love to hear the team's thoughts on this! Happy to provide more details about our use case or help test any proposed solutions. 🙏
Describe the solution
Problem Statement
Currently, there's no practical way to upload Worker code and environment variables/secrets together in a single atomic operation with
wrangler versions upload. This creates challenges for complex deployment scenarios, particularly when coordinating multiple Workers.Current Limitations
1.
--varFlag Issues:.envfiles2.
wrangler secret bulkSeparation:Use Case: Atomic Multi-Worker Deployment
We deploy API and frontend Workers together using this workflow:
Problem: Environment variables using secrets must be managed separately, breaking atomicity and complicating rollbacks.
Current Workaround
We've implemented complex TypeScript scripts that:
.envfiles--varargumentsProposed Solution
Option A: Environment File Support
Option B: Secrets File Support
Option C: Mixed Approach
Benefits
.envecosystemAlternative Considerations
If file-based approach isn't feasible, consider:
Bulk secret upload with version targeting:
Environment inheritance:
Related Issues
This would greatly improve developer experience for:
Workaround Impact
Current workarounds require significant custom tooling and don't provide the security or atomicity that Cloudflare's versioning system otherwise enables.
Would love to hear the team's thoughts on this! Happy to provide more details about our use case or help test any proposed solutions. 🙏