Created
September 21, 2020 03:48
-
-
Save thanakijwanavit/d7951b73fcec13ce635941aa3031d181 to your computer and use it in GitHub Desktop.
invoke a lambda function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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