initial version of counter lambda function
This commit is contained in:
41
example-projects/counter-demo/aws-lambda/invoke-function.py
Normal file
41
example-projects/counter-demo/aws-lambda/invoke-function.py
Normal file
@ -0,0 +1,41 @@
|
||||
import boto3
|
||||
import json
|
||||
|
||||
################################################################################################
|
||||
#
|
||||
# Configuration Parameters
|
||||
#
|
||||
################################################################################################
|
||||
|
||||
region = 'eu-central-1'
|
||||
functionName = 'cloudcomp-counter-lambda-demo'
|
||||
|
||||
|
||||
################################################################################################
|
||||
#
|
||||
# boto3 code
|
||||
#
|
||||
################################################################################################
|
||||
|
||||
|
||||
client = boto3.setup_default_session(region_name=region)
|
||||
lClient = boto3.client('lambda')
|
||||
|
||||
|
||||
print("Invoking function...")
|
||||
print("------------------------------------")
|
||||
try:
|
||||
response = lClient.invoke(
|
||||
FunctionName=functionName,
|
||||
Payload='{ "input": "1" }'
|
||||
)
|
||||
except lClient.exceptions.ResourceNotFoundException:
|
||||
print('Function not available. No need to delete it.')
|
||||
|
||||
streamingBody = response['Payload']
|
||||
result = streamingBody.read()
|
||||
|
||||
print(json.dumps(response, indent=4, sort_keys=True, default=str))
|
||||
|
||||
print('Payload:\n' + str(result))
|
||||
|
Reference in New Issue
Block a user