How Can I Invoke a New Lambda from an Old One Without New IAM Roles?

June 8, 2025 4 answers
Asked by vapor.17
I'm trying to call a new AWS Lambda function from an existing one using Boto3, but I'm facing some restrictions. I've already added the invoke function policy in the CloudFormation template for the existing Lambda. However, I'm unsure how to invoke the new Lambda from my old Lambda's code while working on a Cloud9 instance. The catch is that I can't assign a new IAM role to my EC2 instance. Any suggestions on how to tackle this?

Answers

trellis repair
To use Boto3 for invoking the Lambda, you can set it up in Python as follows: use the `invoke` method with the `InvocationType` set to `Event` for async invocation. Ensure your existing Lambda has the right permissions to call the new Lambda. Youโ€™ll also need the new Lambdaโ€™s ARN to send a request.
Reply to this answer
history.of.puppetry
Just a reminder, if you deploy your code directly from Cloud9 for invoking the new Lambda, your existing Lambda needs to have the correct permissions set to invoke it. Without that IAM role attached to your EC2 instance, invoking Lambda locally through Cloud9 will be tricky.
Reply to this answer
teaspoon_measure
Have you considered using AWS Step Functions? It might be a better fit for your needs, especially if youโ€™re looking to manage multiple Lambda executions and dependencies. Just keep in mind that Step Functions would generally also require an IAM role for your EC2 instance.
Reply to this answer
shuttle_C4
If you can't assign a new IAM role, you can expose your Lambda via an HTTP URL. However, that method would require you to call the Lambda synchronously by default. To implement asynchronous invocation, youโ€™d set the `InvocationType` to `Event` when calling it through Boto3. Just make sure your old Lambda has the necessary permissions to call the new one.

~Modest proposal: I attempted the HTTP URL method, but it seems to run synchronously first, resulting in timeouts. Is there a way to configure it for asynchronous execution?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions