Reference : https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/
Check this answer said : only async lambda execution only work for destination.
Lambda code :
const AWSManager = require('./AWSManager.js');
const request = require('request-promise');
exports.handler = async (event, context) => {
var input = JSON.stringify(event, null, 2);
console.log(event.region);
//console.log("EVENT: \n" + JSON.stringify(event, null, 2))
// TODO implement
var secret_name, region_name;
if(event.secretName){
secret_name= event.secretName;
region_name = event.region;
}else{
secret_name= "test/"
region_name = "us-east-1"
}
console.log(secret_name)
var secret = await AWSManager.getSecret(secret_name)
//console.log('mysecret: ' + secret )
var secret_values = JSON.parse(secret);
//var request = require('request');
var okta_org_url = secret_values['okta_org_url']
var okta_token = secret_values['okta_token']
var api_endpoint = okta_org_url + "api/v1/users?limit=25"
var options = {
'method': 'GET',
'url': api_endpoint,
'headers': {
// header information
}
};
var api_response = await request(options).then(res => res).catch(err => err)
return {
"statusCode": 200
}
};
Code execute properly only SNS destination doesn't work. SNS destination has email protocol subscription for sending email whenever fails.
Found answer it was mistake only.
As per explaination given in AWS Lambda w/ SQS trigger, SQS Lambda Destinations, never adds to destination queue is correct only for calling lambda async you have to run different command. And test input from UI doesn't work like async. It works as sync call. Quoting docs:
When you run a test in the console, Lambda synchronously invokes your function with the test event.
Running asynchronously via a command:
aws lambda invoke \
--function-name lambdaname \
--invocation-type Event \
--payload '{ "name": "Bob" }' \
response.json
Reference : https://docs.aws.amazon.com/cli/latest/reference/lambda/invoke.html#examples
Here is list call support lambda asynchronously and synchronously: