bsmsapp/terraform/resources/lambda/lambdaSQS/lambda_handler.py

27 lines
681 B
Python

import json
import boto3
def start_state_machine(state_machine_arn: str, sqs_message: str):
client = boto3.client('stepfunctions')
response = client.start_execution(
stateMachineArn=state_machine_arn,
input=sqs_message)
print(response)
return response
def main(event, context):
record = event['Records'][0]
print(record)
sqs_message = json.dumps(event)
print(sqs_message)
body = record["body"]
body = body.replace('\n', '')
body = json.loads(body)
query = body["body-json"]
print(query)
start_state_machine(
f"arn:aws:states:us-east-1:025685231147:stateMachine:AWSStepFunctions-g3", sqs_message)