Search code examples
amazon-web-servicesaws-lambdacronpush-notificationfirebase-cloud-messaging

How to schedule a job in AWS to trigger a Lambda at 7:00PM everyday?


How to schedule a job in AWS to trigger a Lambda at 7:00PM everyday?

My use-case is to send push notifications to specific users. I have users in India and US. After processing the DB to identify those users, I will publish the message using Firebase Admin SDK.


Solution

  • You can perform this task using Amazon EventBridge and Cron Expressions.

    Assume you have a Lambda function named employeemsg.

    1. Choose the employeemsg function.

    2. Under Designer, choose Add trigger.

    3. Set the trigger type to CloudWatch Events/EventBridge.

    4. For Rule, choose Create a new rule.

    5. Fill in the Rule name and Rule description.

    6. For rule type, select Schedule expression.

    7. In the Schedule expression field, enter a cron expression. For example, cron(0 12 ? * MON-FRI *).

    8. Choose Add.

    Note: For more information, see Using AWS Lambda with Amazon EventBridge (CloudWatch Events).