serverless / serverless/serverless
Support function arguments in variables referencing javascript ( ${file(./file.js):functionName(argument1, argument2)} )
@zoellner is already working on this.
Since Apr 12, 2021.
- Dominant language
- JavaScript
- Stars
- 46.9k
- Forks
- 5.7k
- Avg merge
- 10h 7m
- Merged PRs (30d)
- 57
Description
This is a Feature Proposal
Description
This is a follow up to #3073 and more specifically to one comment therein https://github.com/serverless/serverless/issues/3073#issuecomment-294636809
Quoting from that comment:
What I think would be a natural and very necessary extension of this work would be to allow you to call a JS file and pass a function arguments to resolve variables. Consider a case where you have a piece of config in a configuration database table (or any other external system), and you want your serverless template to be able to pull a value from the config DB and use it. If you could pass arguments to the JS function, you could make it extensible. For example, the usecase that @tgjorgoski first posted could be more extensible by allowing for this:
custom: someValue: ${file(./variables-helpers.js):getFromS3(secret-data-bucket, secret-data.json)}In that case your JS file would be something like:
module.exports = { getFromS3: function(bucketName, key) { return somePromiseThatLoadsJSONFrom(bucketName, key); } };
Similar or dependent issues:
- #3073
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.