Serverless Cron Jobs & Scheduled Events with AWS Lambda

nader dabit
Instructornader dabit
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

How to create cron jobs and scheduled events with AWS Lambda

Instructor: [0:00] If you've already created a function, you can jump to the 1 minute and 45 second mark. To create the function, we'll first create a new directory and then change into it. Here, we'll run amplify init to create a new Amplify project.

[0:19] Next, give the project a name, an environment name and choose your default text editor. You can then choose default for the rest of the questions. When prompted for your AWS profile, choose the profile that you'd like to use.

[0:48] Once the Amplify project's been initialized, we'll create a new function by running amplify add function. Here, we'll give the local resource a name, the function a name. We'll choose hello world as the function template.

[1:04] Next, we'll choose yes to edit the function locally. In the function, before returning the response, we could log out the event by using console.log. Next, well save the function and deploy it by running amplify push.

[1:32] Once the function has been deployed, we can run amplify console to look at the function within the amplify console. When we click on Functions, we can see logging for the function.

[1:47] To enable a scheduled event, we'll search for CloudWatch in the AWS services. In CloudWatch, click on Events in the left-hand menu and then click Get Started. Here, we'll create a role that's scheduled to run every one minute by clicking by Scheduled with the fix rate of one minute.

[2:11] Next, we'll click Add Target and search for the function that we just deployed. Next, we can take the default input, or we can configure a custom input by passing in JSON.

[2:37] Next, click Configure Details to give the event a name. Once you've given the event a name, click Create Rule. To test this out, wait a couple of minutes, and then refresh the Amplify console to see the event information logged out to the console.

egghead
egghead
~ 4 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today