Task Timer (Lambda, Amazon SNS) - AWS Step Functions

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.


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

  1. Open the Step Functions console and choose Create a state machine.

  2. Choose Sample Projects, and then choose Task Timer.

    The state machine Code and Visual Workflow are displayed.

          Task timer visual workflow.

    The Code section in this state machine references the AWS resources that will be created for this sample project.

  3. Choose Create Sample Project.

    The Create Project 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


    It can take up to 10 minutes for these resources and related IAM permissions to be created. While the Create Project Resources page displays Creating resources, you can open the Stack ID: link to see which resources are being provisioned.

    When complete, the New execution page 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 }
  4. Choose Start Execution.

    A new execution of your state machine starts, and a new page showing your running execution is displayed.

  5. (Optional) In the Execution Details section, choose Info to view the Execution Status and the Started and Closed timestamps.

  6. 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.

          Task timer execution output.