Skip to content

Instantly share code, notes, and snippets.

@djg07
Created September 14, 2019 01:46
Show Gist options
  • Save djg07/7d4b9a7b06459723681b3fef0790ff86 to your computer and use it in GitHub Desktop.
Save djg07/7d4b9a7b06459723681b3fef0790ff86 to your computer and use it in GitHub Desktop.
{
"Comment": "A simple AWS Step Functions state machine that automates a call center support session.",
"StartAt": "ProcessTransaction",
"States": {
"ProcessTransaction": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.TransactionType",
"StringEquals": "PURCHASE",
"Next": "ProcessPurchase"
},
{
"Variable": "$.TransactionType",
"StringEquals": "REFUND",
"Next": "ProcessRefund"
}
]
},
"ProcessRefund": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
},
"ProcessPurchase": {
"Type": "Task",
"Resource": "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME",
"End": true
}
}
}
@cschar
Copy link

cschar commented Feb 11, 2022

corresponding lambda code from earlier in video:

import json
import datetime
import urllib
import boto3


def lambda_handler(message, context):
    # TODO implement

    print("received messsage from step fn")
    print(message)

    response = {}
    response['TransactionType'] = message['TransactionType']
    response['Timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H-%M-%S")
    response['Message'] = "Hello from process purchase lambda"


    return response
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment