You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
import boto3
|
|
import json
|
|
|
|
################################################################################################
|
|
#
|
|
# Configuration Parameters
|
|
#
|
|
################################################################################################
|
|
|
|
# region = 'eu-central-1'
|
|
region = 'us-east-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))
|
|
|