forked from servian/aws-step-function-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda-invoke-step-function.py
More file actions
35 lines (27 loc) · 878 Bytes
/
lambda-invoke-step-function.py
File metadata and controls
35 lines (27 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
import boto3
import pprint
#initialize
pp = pprint.PrettyPrinter(indent=4)
def lambda_handler(event, context):
'''
triggers a step function from the S3 landing event,
passing along the S3 file info
'''
#Fallback tests for initializations outside scope
try:
pp
except NameError:
pp = pprint.PrettyPrinter(indent=4)
bucket_name = event['Records'][0]['s3']['bucket']['name']
file_key = event['Records'][0]['s3']['object']['key']
input= {
'bucket_name': bucket_name,
'file_key': file_key
}
stepFunction = boto3.client('stepfunctions')
response = stepFunction.start_execution(
stateMachineArn='arn:aws:states:XXXXXXXXXXXXXXXX:stateMachine:my-state-machine',
input = json.dumps(input, indent=4)
)
return pp.pprint(response)