5

I would like to offload some functionality from my Lambda@Edge to speed up response time. This would mean triggering another Lambda Function inside my Lambda@Edge.

Lambda@Edge distributes the application across all regions, so when a request is made it would execute the application in the region closest to the requester.

My current solution is to create an SNS with the same topic name on all regions, have an SQS in us-east-1 listen to all these SNS Topics, and the Lambda function to listen to the SQS.

However, creating an SNS on every region is quite a hassle to maintain.

Any other suggestions on how I can trigger another Lambda function inside my Lambda@Edge?

Thanks!

1
  • How does your current solution relate to your problem? Do you use SNS and SQS to trigger Lambda from another Lambda? Commented Dec 20, 2019 at 21:54

1 Answer 1

1

Within lambda you can simply make the call to another lambda. I don't know which language you are using, but here is an example in Python and the boto3 library with a sample payload of information you may want to pass on to the lambda being invoked (I used region and detail-type as example info to pass along):

payload = {'region': <the region>, 'detail-type': 'some other detail you care about'}
lambda_client = boto3.client('lambda', account_id=<your account ID>)
lambda_client.invoke(FunctionName=<ARN of the function you want to invoke>, InvocationType='Event', Payload=json.dumps(payload))

Similar options are available in other languages. More details for this call in Python are at https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.invoke

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.