Reputation: 5556
I have an env.yml
file where I store some variables that should be be sent to the serverless.yml
. I want to send this array of variables from the env.yml
to the serverless.yml
.
This. is what I have in the env.yml
securityGroupIds:[sg-xxx]
subnetIds: [subnet-xx1, subnet-xx2, subnet-xx3, subnet-xx4]
This is what I have in the serverless.yml
:
vpc:
securityGroupIds: ${file(env.yml):securityGroupIds}
subnetIds: ${file(env.yml):securityGroupIds}
And this is what I was expecting to get inside serverless.yml
when I sls print --stage dev
:
vpc:
securityGroupIds:
- sg-xxx
subnetIds:
- subnet-xx1
- subnet-xx2
- subnet-xx3
- subnet-xx4
It is not working. What am I doing wrong?
Upvotes: 3
Views: 3034
Reputation: 5556
I have found the way:
in the env.yml
:
vpc-dev: {
"securityGroupIds": [
"sg-xxx"
],
"subnetIds": [
"subnet-xx1",
"subnet-xx2",
"subnet-xx3",
"subnet-xx4"
]
}
vpc-prod: {
"securityGroupIds": [
"sg-xxxy"
],
"subnetIds": [
"subnet-xx1y",
"subnet-xx2y",
"subnet-xx3y",
"subnet-xx4y"
]
}
in the serverless.yml
function
hello: ...
handler: ...
...
vpc: ${file(env.yml):vpc-${self:provider.stage}}
Upvotes: 6