Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serverless variable from external file nested property

I have serverless yml and a config file

config file

 app: {
   port: 3000,

 db: {
   connectionString: 'xxxxx'
 },
  lambdaDeploy:{
   stage : "DEV",
   region : "es-west-1"
 }

Trying to use these variables in yml like below

yml

provider:
  name: aws
  runtime: nodejs6.10
  stage: ${file(./appconfiguration.json).app.stage}
  region: ${file(./appconfiguration.json).app.region}

But its reading and taking default

Please advise. Thanks

like image 422
Md. Parvez Alam Avatar asked Sep 03 '26 13:09

Md. Parvez Alam


1 Answers

The syntax used here is not correct.

stage: ${file(./appconfiguration.json).app.stage}

Use colon instead:

stage: ${file(./appconfiguration.json):app.stage}

More details here: https://www.serverless.com/framework/docs/providers/aws/guide/variables/#reference-variables-in-other-files

like image 193
Mina Luke Avatar answered Sep 07 '26 00:09

Mina Luke