Following the documentation, I tried declaring environment variables in the serverless.yml file under provider:
provider:
cfLogs: true
name: aws
runtime: nodejs4.3
stage: dev
region: eu-west-1
profile: serverless-admin
environmnent:
IS_REMOTE: ${file(./config.yml):IS_REMOTE}
REMOTE_ENV: "YES"
None of these are available to me when trying to get them using process.env.IS_REMOTE or process.env.REMOTE_ENV.
This is the log of trying to console.log them:
2017-01-01 06:22:57.777 (+02:00) undefined REMOTE_ENV: undefined
2017-01-01 06:22:57.777 (+02:00) undefined IS_REMOTE: undefined
This is inside Lambda when using serverless invoke
(not locally).
Hope someone can help me figure this out, as it seems like I'm following the docs about right.
This feature works fine for me. I believe that you have mistyped something.
Could you please create a new project and test the following steps? Maybe we can find what is your issue through a MCVE. Give me a feedback if this code does not work for you.
Check your Serverless version (expected: 1.4.0)
Create a new project
Use the following serverless.yml
Use the following handler.js
Deploy
Test
HTTP result:
Log: