Starting the execution of the Step Function State Machine via AWS Console to call the SNS Publish API from a Task state. The State Machine accepts values in a JSON format (please see sample payload) and will execute the SNS Publish API to send a message to the configured SNS Topic.
{
"StartAt": "step-function-definition",
"States": {
"step-function-definition": {
"End": true,
"Type": "Task",
"ResultPath": null,
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"TopicArn": "arn:aws:sns:us-east-1:123456789101:step-function-topic",
"Message.$": "$.content",
"Subject.$": "$.subject"
}
}
}
}
{
"subject": "Alert #17052023FB0508",
"content": "Hello John,\n\nWe regret to inform you that your application, XYZ, encountered an error. The error message is as follows:\n\n\tAn unexpected error occurred while processing your request. Please take note of the following details for troubleshooting:\n\t\tError Message: Invalid input format for parameter 'transaction'. Expected a string value.\n\t\tRequest ID: 79dcbfaa-123b-40c2-b632-1110a21a6063\n\t\tTimestamp: 2023-05-17 10:15:23 UTC\n\nIf you have any questions or concerns, please contact our support team at [email protected]."
}
- AWS Step Functions
- Amazon CloudWatch Logs
- Tasks for Steps Functions
- Amazon Simple Notification Service
- States
- Amazon States Language
- AWS Step Function Guides
- Service Integration Patterns
- Call Amazon SNS with Step Functions
- Input and Output Processing in Step Functions
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
-
Install all the dependencies, bootstrap your project, and synthesized CloudFormation template.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sns$ make init # With "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sns$ make init profile=[profile_name]
-
Deploy the project.
# Without passing "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sns$ make deploy # With "profile" parameter dev@dev:~:aws-cdk-samples/step-functions/step-functions-sns$ make deploy profile=[profile_name]