Open hschimpf opened 1 year ago
Thanks for the PR! I'm afraid this is extra logic to maintain, and the feature doesn't have great DX (creating a special syntax) 🤔
What is the use case for you? Where have you seen that need?
What is the use case for you? Where have you seen that need?
As serverless allows to set default values on variables, I already have some variables that have a default value when it's not present on the .env
file.
For example, these are my current serverless.yml
environment variables:
serverless.yml
provider:
environment:
DB_HOST: ${env:SLS_DB_HOST}
DB_DATABASE: ${env:SLS_DB_DATABASE, self:custom.UUID}
DB_USERNAME: ${env:SLS_DB_USERNAME, self:custom.UUID}
DB_PASSWORD: ${env:SLS_DB_PASSWORD}
custom:
UUID: ${self:service}-${self:provider.stage}
The UUID
is generated using the service name and the current deployment stage. So when I deploy to production, the username and database is generated from the UUID
. And if in the CI/CD the SLS_DB_DATABASE
or SLS_DB_USERNAME
is set, it will be used instead of the default value.
I want to update those values to bref-ssm
to store them on AWS SSM Parameters, and if they don't exist, use the generated value using UUID
like this:
serverless.yml
provider:
environment:
DB_HOST: bref-ssm:/${param:UUID}/DB_HOST
DB_PORT: bref-ssm:/${param:UUID}/DB_PORT,3306
DB_DATABASE: bref-ssm:/${param:UUID}/DB_DATABASE,${self:custom.UUID}
DB_USERNAME: bref-ssm:/${param:UUID}/DB_USERNAME,${self:custom.UUID}
DB_PASSWORD: bref-ssm:/${param:UUID}/DB_PASSWORD
custom:
UUID: ${self:service}-${self:provider.stage}
Hello!
I'm thinking about the possibility to define a default value for parameters that don't exist on SSM.
Just have one question:
Since the name can't have the colon symbol in it, you think that it could be the separator @mnapoli?