Using the Serverless framework, I want to be able to change the AWS region from an envrionment variable.
provider:
name: aws
region: ${env:AWS_REGION}
Then, AWS_REGION can be set to eu-west-2.
However, I want to have that set in a .env file:
AWS_REGION=eu-west-2
And then have that .env read by Serverless.
There are many topics about setting variables in the serverless.yml file, and exporting them from that file, but I want to put them into the file.
Serverless now supports .env files without the need for a plugin
Add useDotenv: true to your serverless.yml file. The variable should be at the root level, same as service: ...
Add a .env file at the root of your project and serverless will load the variables.
Example:
// .env
MY_TABLE=A_TABLE_NAME
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With