Any way to "flatten" an object in a var?

I have an object that’s stored in a variable, and I need to include it in my Lambda env vars, e.g.:

functions:
  rdsConnector:
    handler: src/rds.handler
    environment: 
      STAGE: ${self:custom.stage}
      ...${self:custom.dbCreds}

I’m just using the JavaScript ES6 spread operator as an example of what I want to do. How can I do this in the serverless.yml file?

1 Like