Cross Account + Cross Region Lambda invocation

import json
import boto3
def lambda_handler(event, context):
# mention cross region here
client = boto3.client('lambda', region_name='us-west-1')
# function you need to invoke from cross account/region
response = client.invoke(FunctionName='arn:aws:lambda:us-west-1:110987654321:function:invokee', InvocationType='RequestResponse')

responsefinal = json.load(response['Payload'])
print(responsefinal)
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda from invoker function!')
}
import json
import boto3
def lambda_handler(event, context):
# TODO implement
boto3.client('lambda',region_name='us-west-1')
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda from invokee!')
}
{
"Version": "2012–10–17",
"Statement": {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::110987654321:role/service-role/invokee-role"
}
}
{
"Version": "2012–10–17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789101:role/service-role/invoker-function-eu-west2-role"
},
"Action": "sts:AssumeRole"
}
]
}
{
"Version": "2012–10–17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789101:role/service-role/invoker-function-eu-west2-role"
},
"Action": "sts:AssumeRole"
}
]
}
{
"Version": "2012–10–17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "lambda:InvokeFunction",
"Resource": "arn:aws:lambda:*:*:*"
}
]
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store