- Create a Lambda function, which will receive the lambda invocation, choose python 3.7 or upper as your runtime, you can use the AWS default role or choose your predefined role and lastly copy the sample function (
child_lambda.py
) below. - Copy the function's ARN then head over to AWS IAM service and navigate to policies
- Click on Create policy
- Click the JSON icon, copy and paste the
policy.json
below - Replace the "Resource" value in the
policy.json
with the ARN of the Lambda function - Click on Review policy and give a name and description to your policy and then create policy
- Head over to IAM and click on Roles, create a new role, click on Lambda as the AWS service then click on Permissions and tick the AWSLambdaBasicExecutionRole and also tick the new policy role you just created and lastly click on Tags
- Give the new role you created a name and description.
- Head over to AWS Lambda and create a new lambda which will send the invocations to the function you've created previously. Select your prefered runtime and choose the role you created in the step above.
- You can copy the code in the
parent_lambda.py
and add your enviromental variable(AWS account id, function name and region) in the lambda function. - And if you run the function you'll see the child function will be invoked and also the response of the function you just invoked in the parent's function.
**Note: This can only happen across regions**