I need to invoke the lambda function from the shell script which is in ec2 instance. Is it possible to invoke that. If yes what are the steps to be followed. My requirement is when one job is finished in ec2 ,then main script should execute the lambda function
2 Answers
2
votes
While it is indeed possible, depending on the scale of the task, AWS Step Functions are better suited for orchestrating workflows between different services.
If you're adamant about doing it on EC2 instance, you need to:
Create role which can be assumed by EC2 instance and allows for invoking target lambda function
Attach role to the instance
Install AWS CLI on the instance and use
aws lambda invokecommand as described here: https://docs.aws.amazon.com/cli/latest/reference/lambda/invoke.html