-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
Milestone
Description
This is a Feature Proposal
Description
Serverless has very nice variables support. Among other things it allows for variable values to be generated dynamically by specifying functions to call. E.g. from the documentation:
${file(../myCustomFile.js):hello}
Here the hello method from myCustomFile.js can return e.g. some string, and the variable would be replaced with that string.
However, in some cases figuring out the value might require async. calls. It would be nice if serverless would accept Promises as return values instead of just values.
The exact use case I was trying to do is retrieving some secret ID from an s3 bucket, and putting it in the lambda environment variables.
As far as I can see, there is no other way to use the result of this snippet within the sls (except writing a plugin, I guess).
bucket.getObject(
{
Bucket: "secret-data-bucket",
Key: "secret-data.json"
}
).promise()
.then(data => {
let object = JSON.parse(data.Body.toString());
resolve(object.secretID);
})
terev and adambiggs