Serverless Compose with Regions with env variables

I am working to get our serverless stack (which contains multiple services) deployed to different regions.
I read this guide about compose Serverless Framework - Composing services. In the FAQ it says it doesn’t support deploying to multiple regions.
But our team found a way using environment variables.
We simply set the region in the provider of each service to ${env:REGION, ‘us-east-1’}, export REGION=[whatever region we want] and then run sls deploy.
The env var gets picked up correctly, and deploys to the right region.

I’m not sure why the FAQs say it’s not possible. I get it’s not possible with the cli args, but this workaround works well. Anyway just hoping it helps someone else out down the road (or for someone to tell me we’re doing something horribly wrong for some reason that I can’t see)

What they are mentioning is that you cannot deploy the same service to multiple regions.
You can deploy different service to different regions, just like what you are doing.

1 Like