4

I have a serverless.yml which looks like this

service: my-service

provider:
  name: aws
  runtime: python3.7
  versionFunctions: false

  environment:
    ACCOUNT_ID: "${file(./serverless.env.yml):${self:provider.stage}.account_id}"
    ANOTHER_VARIABLE: "some text ${ACCOUNT_ID} some other text"

Here, I want to reference the existing environment ACCOUNT_ID in ANOTHER_VARIABLE. The ${ACCOUNT_ID} doesn't work. I also tried to look at the serverless documentation but I'm not able to find anything related to that.

Ganesh Satpute
  • 3,664
  • 6
  • 41
  • 78

1 Answers1

5

You can simply use ${self:provider.environment.ACCOUNT_ID}.

service: my-service

provider:
  name: aws
  runtime: python3.7
  versionFunctions: false

  environment:
    ACCOUNT_ID: "${file(./serverless.env.yml):${self:provider.stage}.account_id}"
    ANOTHER_VARIABLE: "some text ${self:provider.environment.ACCOUNT_ID} some other text"
Shay Ashkenazi
  • 467
  • 1
  • 4
  • 11