Skip to content

Instantly share code, notes, and snippets.

@thanakijwanavit
Created September 21, 2020 03:48
Show Gist options
  • Select an option

  • Save thanakijwanavit/d7951b73fcec13ce635941aa3031d181 to your computer and use it in GitHub Desktop.

Select an option

Save thanakijwanavit/d7951b73fcec13ce635941aa3031d181 to your computer and use it in GitHub Desktop.
invoke a lambda function
class Lambda:
'''
for invoking lambda functions
'''
def __init__(self, user=None, pw=None, region = 'ap-southeast-1'):
self.lambdaClient = boto3.client(
'lambda',
aws_access_key_id=user,
aws_secret_access_key=pw,
region_name = region
)
def invoke(self, functionName, input):
return self.lambdaClient.invoke(
FunctionName = functionName,
InvocationType= 'RequestResponse',
LogType='Tail',
ClientContext= base64.b64encode(json.dumps({'caller': 'sdk'}).encode()).decode(),
Payload= json.dumps(input)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment