Skip to content

Instantly share code, notes, and snippets.

@bahrmichael
Created November 4, 2020 12:11
Show Gist options
  • Save bahrmichael/97180d6f9e0157973b10c6c35e969f58 to your computer and use it in GitHub Desktop.
Save bahrmichael/97180d6f9e0157973b10c6c35e969f58 to your computer and use it in GitHub Desktop.
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Create pending order",
"States": {
"Create pending order": {
"Type": "Pass",
"Next": "Select Payment Method"
},
"Select Payment Method": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.type",
"StringEquals": "Free",
"Next": "Free"
},
{
"Variable": "$.type",
"StringEquals": "SEPA",
"Next": "SEPA"
},
{
"Variable": "$.type",
"StringEquals": "PayPal",
"Next": "PayPal"
},
{
"Variable": "$.type",
"StringEquals": "CreditCard",
"Next": "CreditCard"
}
]
},
"Free": {
"Type": "Pass",
"Next": "Order Paid"
},
"PayPal": {
"Type": "Pass",
"Next": "Create PayPal Payment Intent"
},
"Create PayPal Payment Intent": {
"Type": "Pass",
"Next": "Wait for User to complete PayPal payment"
},
"Wait for User to complete PayPal payment": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
"Parameters": {
"QueueUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/myQueue",
"MessageBody": {
"Message": "Hello from Step Functions!",
"TaskToken.$": "$$.Task.Token"
}
},
"Next": "Capture PayPal Payment"
},
"Capture PayPal Payment": {
"Type": "Pass",
"Next": "Order Paid"
},
"CreditCard": {
"Type": "Pass",
"Next": "Create CreditCard Payment Intent"
},
"Create CreditCard Payment Intent": {
"Type": "Pass",
"Next": "Wait for user to complete CreditCard Payment"
},
"Wait for user to complete CreditCard Payment": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
"Parameters": {
"QueueUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/myQueue",
"MessageBody": {
"Message": "Hello from Step Functions!",
"TaskToken.$": "$$.Task.Token"
}
},
"Next": "Capture CreditCard Payment"
},
"Capture CreditCard Payment": {
"Type": "Pass",
"Next": "Order Paid"
},
"SEPA": {
"Type": "Pass",
"Next": "Charge Source SEPA"
},
"Charge Source SEPA": {
"Type": "Pass",
"Next": "Wait for SEPA Payment to complete"
},
"Wait for SEPA Payment to complete": {
"Type": "Task",
"Resource": "arn:aws:states:::sqs:sendMessage.waitForTaskToken",
"Parameters": {
"QueueUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/myQueue",
"MessageBody": {
"Message": "Hello from Step Functions!",
"TaskToken.$": "$$.Task.Token"
}
},
"Next": "Record SEPA Payment"
},
"Record SEPA Payment": {
"Type": "Pass",
"Next": "Order Paid"
},
"Order Paid": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "Update Order to paid",
"States": {
"Update Order to paid": {
"Type": "Pass",
"End": true
}
}
},
{
"StartAt": "Create Tickets PDF",
"States": {
"Create Tickets PDF": {
"Type": "Pass",
"End": true
}
}
},
{
"StartAt": "Create Tickets Wallet Passes",
"States": {
"Create Tickets Wallet Passes": {
"Type": "Pass",
"End": true
}
}
}
],
"Next": "Send Mail"
},
"Send Mail": {
"Type": "Pass",
"Next": "Order Shipped"
},
"Order Shipped": {
"Type": "Parallel",
"Branches": [
{
"StartAt": "Update Order to shipped",
"States": {
"Update Order to shipped": {
"Type": "Pass",
"End": true
}
}
},
{
"StartAt": "Notify organizer of new order",
"States": {
"Notify organizer of new order": {
"Type": "Pass",
"End": true
}
}
},
{
"StartAt": "Run Aggregation",
"States": {
"Run Aggregation": {
"Type": "Pass",
"End": true
}
}
}
],
"End": true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment