I need to call some endpoint of my application periodically. I understand that i can create aws lambda function that will be triggered by aws trigger and that lambda will call my rest endpoint. Can aws lambda be avoided here? In other words, is it possible to make aws trigger to call my rest endpoint instead of aws lambda function?
2 Answers
Things that could trigger a REST endpoint:
- A script/application on an Amazon EC2 instance, triggered by a cron schedule
- An AWS Lambda function triggered by an Amazon CloudWatch Events schedule
- An Amazon Simple Notification Service (SNS) topic with your REST endpoint as a subscriber, triggered by an Amazon CloudWatch Events schedule
For the SNS option, you won't have much control over the content of the call but it can call an endpoint.
-
Note that for the third option of using SNS to hit a REST endpoint, it is simple, but you'll need to initially confirm the subscription. When you add the REST endpoint, SNS will send a message to the endpoint with a "SubscribeURL" with a link you'll need to visit before SNS can start sending messages there. You'll need a way to dump the body of the message. docs.aws.amazon.com/sns/latest/dg/… Mar 15, 2020 at 5:02
Since this is still one of the top search results for these terms, this question deserves a 2021 update.
John's answer was comprehensive at the time he wrote it, but nowadays you don't have to jump through the same silly hoops as you used to. Now you can set up an EventBridge "rule" that triggers on a "cron" schedule, and that rule can have an "API Destination" target that provides a URL and an associated "Connection," which specifies things like authentication methods.
This can be set up in the console or via CloudFormation, and should be the simplest way to set up periodic calls to REST endpoints in the majority of cases.