I have a NodeJS server running on an EC2 instance, orchestrated by Elastic Beanstalk.
I would like to create a Lambda function that is triggered upon certain events in AWS Cognito. I want the Lambda function to make a POST call to my NodeJS server.
How can this be done?
As far as I know, EC2 and Lambda are not integrated out of the box. You'll need to expose your EC2 endpoint through a web-server (e.g. Apache) to receive HTTP requests. Then you send a GET or POST request from Lambda to the EC2 server.
You could have both running in a VPC, so that the IP address you use to make requests to your EC2 web-server is only reachable from within your VPC. It won't make your EC2 callable only by the Lambda function but will prevent the external world from calling your EC2 server.
This tutorial might be useful to you: Configuring a Lambda Function to Access Resources in an Amazon VPC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With