Task Timer (Lambda, Amazon SNS)
This sample project creates a task timer. It implements an AWS Step Functions state machine that
implements a Wait
state, and uses an AWS Lambda function that sends an Amazon Simple Notification Service
(Amazon SNS) notification. A Wait
state is a state type that waits for a trigger to
perform a single unit of work.
Note
This sample project implements an AWS Lambda function to send an Amazon Simple Notification Service (Amazon SNS) notification. You can also send an Amazon SNS notification directly from the Amazon States Language. See Using AWS Step Functions with other services.
This sample project creates the state machine, a Lambda function, and an Amazon SNS topic, and configures the related AWS Identity and Access Management (IAM) permissions. For more information about the resources that are created with the Task Timer sample project, see the following:
For more information about how AWS Step Functions can control other AWS services, see Using AWS Step Functions with other services.
To create the Task Timer state machine and provision all resources
-
Open the Step Functions console
and choose Create state machine. -
Choose Run a sample project, and then choose Task Timer.
The state machine Definition and Visual Workflow are displayed.
Note
The Definition section in this state machine references the AWS resources that will be created for this sample project.
-
Choose Next.
The Deploy resources page is displayed, listing the resources that will be created. For this sample project, the resources include:
-
A SendToSNS Lambda function
-
A TaskTimerTopic Amazon SNS topic
-
-
Choose Deploy resources.
Note
It can take up to 10 minutes for these resources and related IAM permissions to be created. While the Deploy resources page is displayed, you can open the Stack ID link to see which resources are being provisioned.
When complete, the Start execution dialog box is displayed, with example input similar to the following.
{ "topic": "arn:aws:sns:us-east-2:123456789012:StepFunctionsSample-TaskTimer-517b8680-e0ad-07cf-feee-65aa5fc63ac0-SNSTopic-96RHT77RAKTS", "message": "HelloWorld", "timer_seconds": 10 }
-
Choose Start Execution.
A new execution of your state machine starts, and a new page showing your running execution is displayed.
-
(Optional) In the Execution Details section, choose Info to view the Execution Status and the Started and Closed timestamps.
-
To view the status, input, or output of each step in your execution, select the step in the Visual workflow and review the Step details.