Allow me inform you some helpful info regarding FIFA 18

Did you know that FIFA 18 will be formally released on 29th September 2017? If you beloved this report and you would like to get far more data with regards to fifacoinsstop kindly check out the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Programmatically Schedule Tasks using AWS CloudWatch and Lambdas Serverless

Scheduling tasks on AWS without polling and managing queues is effortless using Lambdas and CloudWatch in conjunction. Like sending scheduled (dynamic time) emails on daily, weekly or monthly basis. What we’ll do is define a CloudWatch rule giving it the cron expression as to when it should trigger. When defining a rule we can also give it a target to invoke when the rule triggers on its given time. That target could be anything a WebHook, a lambda function or a message queue. We’ll make a CloudWatch rule to trigger after every 5 minutes with and invoke a Lambda function upon it’s trigger with some static data to be sent to the Lambda function Let’s dive right in

Initialise your constants

Next we need to add a rule to CloudWatch. Rule has a unique Name to it and it’s ScheduleExpression. ScheduleExpression is a cron or rate expression which specifies when you want this rule to trigger. We’re going to trigger it every 5 mintues

Now we’re going to use data.ruleArn from the putRule to grant permission to the Lambda itself so that it can be invoked from someother source. We’ll add this permission into Lambda

Lastly we’re going to add the target of this rule. Target is any AWS service this rule will invoke when it gets triggered. Our target is the lambda function above to which we just added the permission.

That is it. Now after every 5 minutes this rule will trigger and invoke our lambda function with the Input data we’ve given to it.

Your data in lambda can be accessed in the event

One last thing is that you can promisify all the functions to save yourself from the callback hell. Here’s the promisfied version of all the code above amalgamated into single function. Cheers!

Add a comment

Related posts:

Progressive Muscle Relaxation in Outer Space

Progressive muscle relaxation is an easy, portable, and useful technique that can calm an amygdala-based anxiety attack. A surprising tip from Project Hail Mary.

Facing the Fire

Last weekend I joined in with a group of friends at a guided glass-blowing experience. The three artisans explained the process, showed us the tools and the ovens (heated to over 2000 degrees), and…

Do You Put All Your Eggs Into One Basket When It Comes To Manifesting More Money?

Often we see that money is the only way that we can get the house and car we want, or the dream life that we want or that getting more money is our only way to pay the bills and keep a roof over our…