'How to get Lambda functions configuration using async await?
I want to get the configuration of a lambda function using the GetFunctionConfiguration API.
Currently the code I am using is based on callbacks but I want to transform it to use async await.
var params = {
FunctionName: "my-function",
};
lambda.getFunctionConfiguration(params, function (err, data) {
// Do Something
});
Solution 1:[1]
You can promisify your function with
const util = require('util');
const getFunctionConfiguration = util.promisify(lambda.getFunctionConfiguration);
and call it with
const data = await getFunctionConfiguration(params);
You can find more on promisify here: https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thomas Sablik |
