Skip to content

Instantly share code, notes, and snippets.

@mikaeelkhalid
Last active March 12, 2023 15:48
Show Gist options
  • Select an option

  • Save mikaeelkhalid/4f3b10070620583579b5a4c9b1bc60be to your computer and use it in GitHub Desktop.

Select an option

Save mikaeelkhalid/4f3b10070620583579b5a4c9b1bc60be to your computer and use it in GitHub Desktop.
import json
import boto3
client = boto3.client('lambda')
def lambda_handler(event, context):
inputForInvoker = {'Id': '1', 'Price': 100 }
response = client.invoke(
FunctionName='YOUR LAMBDA ARN',
InvocationType='RequestResponse', # Or Event
Payload=json.dumps(inputForInvoker)
)
responseJson = json.load(response['Payload'])
print(responseJson)
# AWSLambdaBasicExecutionPolicy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
# InvokeOtherLambdaPolicy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction",
"lambda:InvokeAsync"
],
"Resource": "arn:aws:lambda:*:*:function:*"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment