1 Answer
- Newest
- Most votes
- Most comments
0
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda({ region: 'your-region' });
async function getSecret() {
const params = {
FunctionName: 'YourLambdaFunctionName',
InvocationType: 'RequestResponse',
};
try {
const result = await lambda.invoke(params).promise();
return JSON.parse(result.Payload.toString());
} catch (error) {
console.error('Error getting secret:', error);
throw error;
}
}
// Use this in your test
(async () => {
const secret = await getSecret();
// Use secret here
})();
answered 2 years ago
Relevant content
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago

Thanks Hikaru, my question isn't really about how to use the aws-sdk, as much as how to grant the running test permissions to invoke lambdas or retrieve secrets. Does the test execute using an aws role? If so, what is the role and how do I grant it access to a lambda or secret?