Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Amazon EventBridge Scheduler to send messages to Amazon SQS

Created with SnapEventBridge SchedulerSQS

Simple pattern that publishes a message to an SQS queue every 5 minutes

This sample pattern demonstrates how to send a message to an Amazon SQS queue every 5 minutes using EventBridge Scheduler and deployed using the AWS Serverless Application Model (SAM).

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Description: (uksb-1tthgi812) (tag:eventbridge-schedule-to-sqs-sam)
Resources:
  TargetSQSQueue:
    Type: AWS::SQS::Queue
    Properties:
      QueueName: EventBridgeTargetQueue
  SqsSchedule:
    Type: AWS::Scheduler::Schedule
    Properties:
      ScheduleExpression: 'rate(5 minute)'
      Name: SqsSendMessageSchedule
      Description: Sends a message to SQS every 5 minutes
      Target:
        Arn: !GetAtt TargetSQSQueue.Arn
        Input: "This message was sent using EventBridge Scheduler!"
        RoleArn: !GetAtt SchedulerRole.Arn
      FlexibleTimeWindow:
        Mode: 'OFF'
  SchedulerRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service: scheduler.amazonaws.com
            Action: sts:AssumeRole
      Path: "/"
      Policies:
        - PolicyName: SqsSendMessagePolicy
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action: sqs:SendMessage
                Resource: !GetAtt TargetSQSQueue.Arn


      

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/eventbridge-schedule-to-sqs-sam

Deploy

See the GitHub repo for detailed deployment instructions.


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Presented by Tadhg O'Brien

Tadhg is a Technical Account Manager at Amazon Web Services supporting Public Sector customers and has a passion for Serverless

Follow on LinkedIn