cloudflare / serverless-cloudflare-workers

Serverless provider plugin for Cloudflare Workers
BSD 3-Clause "New" or "Revised" License
175 stars 37 forks source link

Improvement to way we suggest environment variables #35

Open exvuma opened 5 years ago

exvuma commented 5 years ago

Docs currently suggest that best practice is to set the env variables CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_AUTH_EMAIL, CLOUDFLARE_AUTH_KEY, CLOUDFLARE_ZONE_ID in their environment variables every time they run a script

The best practice is to maintain a set of config files config/dev.yml that contains stage-specific config and then read these vars into the serverless.yml e.g.

custom:
  deployVars: ${file(./config/config.${opt:stage}.yml)}

provider:
  name: cloudflare
  config:
    accountId: ${self:custom.deployVars.CLOUDFLARE_ACCOUNT_ID}
    zoneId: ${self:custom.deployVars.CLOUDFLARE_ZONE_ID}
matt-lethargic commented 5 years ago

I think this would be very useful to see changed in the docs.

"that turns your version-controlled code into Workers" - this I've seen written a few times, but there is no where to help you getting a CI/CD pipeline built if you are new to workers built using the serverless framework.

Having CLOUDFLARE_ACCOUNT_ID etc in the environment vars on my laptop doesn't help when the worker is built on a build agent!