<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lambda Archives | Cloudar</title>
	<atom:link href="https://cloudar.be/tag/lambda/feed/" rel="self" type="application/rss+xml" />
	<link>https://cloudar.be/tag/lambda/</link>
	<description>100% Focus On AWS // 100% Customer Obsession</description>
	<lastBuildDate>Mon, 23 Mar 2020 12:17:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Let&#8217;s trash talk!</title>
		<link>https://cloudar.be/awsblog/lets-trash-talk/</link>
		
		<dc:creator><![CDATA[Michiel Vanderlinden]]></dc:creator>
		<pubDate>Mon, 23 Mar 2020 12:17:59 +0000</pubDate>
				<category><![CDATA[AWS Blog]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[cloudformation]]></category>
		<category><![CDATA[cloudwatch]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[SAM]]></category>
		<category><![CDATA[sns]]></category>
		<guid isPermaLink="false">https://www.cloudar.be/?p=16571</guid>

					<description><![CDATA[<p>Hi all, in this blogpost I will give a brief overview of how I used AWS to remind me to take out the trash. It’s a familiar scene: as you’re waking up or making your morning coffee, you hear the garbage truck roaring away outside when you suddenly realize your garbage bags are still rotting [&#8230;]</p>
<p>The post <a href="https://cloudar.be/awsblog/lets-trash-talk/">Let&#8217;s trash talk!</a> appeared first on <a href="https://cloudar.be">Cloudar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Hi all, in this blogpost I will give a brief overview of how I used AWS to remind me to take out the trash.</p>
<p>It’s a familiar scene: as you’re waking up or making your morning coffee, you hear the garbage truck roaring away outside when you suddenly realize your garbage bags are still rotting away in the garage. Do you run after the truck like a lunatic, even though it’s too late (of course I’ve never done this, but I’ve heard it’s a thing)? Or do you just let it go and let the garbage fester even longer? Either way, it’s a frustrating start to the day.</p>
<p>Luckily for me I live in the modern and very civilised province of Limburg of Belgium where the local government has made a website available with a downloadable calendar showing all dates the garbage truck comes along: so handy! They even provide the calendar in a number of digital formats, including iCal. I could just import this into my phone and set an alert on it, but where’s the fun in that? After some fiddling around or “reverse engineering” as they call it, I found out that the data for the calendar files was provided by an undocumented but publicly available API.</p>
<p>Being the sucker for coding up and fooling around with APIs that I am (and given my state of utter boredom while under full lockdown in Belgium) I decided to code up a project based on this API that would send me an SMS notification the evening before garbage collection. Because that’s my idea of fun. And that way I would be reminded to take out the trash on time and keep my garage clean.</p>
<p>Want to know this neat trick to save you from rubbish resentment? Read on!</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-16575" src="https://cloudar.be/wp-content/uploads/2020/03/1-650x433.png" alt="reverseengineering" width="650" height="433" srcset="https://cloudar.be/wp-content/uploads/2020/03/1-650x433.png 650w, https://cloudar.be/wp-content/uploads/2020/03/1-1300x867.png 1300w, https://cloudar.be/wp-content/uploads/2020/03/1-325x217.png 325w" sizes="(max-width: 650px) 100vw, 650px" /></p>
<p>So for this project I partly used the AWS SAM framework and set up a CodePipeline to deploy my code changes instantly on AWS (stay tuned for a future blogpost on this).</p>
<p><img decoding="async" class="alignnone wp-image-16578 size-thumbnail" src="https://cloudar.be/wp-content/uploads/2020/03/pipeline-325x217.png" alt="codepipeline" width="325" height="217" srcset="https://cloudar.be/wp-content/uploads/2020/03/pipeline-325x217.png 325w, https://cloudar.be/wp-content/uploads/2020/03/pipeline-650x433.png 650w" sizes="(max-width: 325px) 100vw, 325px" /></p>
<p>First let’s code up the AWS SAM template file containing the necessary resources for this project.</p>
<p>The resources I used are:</p>
<ul>
<li>Type: AWS::Events::Rule<br />
A Cloudwatch event rule to invoke a lambda each evening around 8.</li>
<li>Type: AWS::Lambda::Permission<br />
To give the Cloudwatch event rule permissions to invoke the lambda.</li>
<li>Type: AWS::Logs::LogGroup<br />
A log group for the lambda logs.</li>
<li>Type: AWS::Serverless::Function<br />
The lambda that will run the show.</li>
<li>Type: AWS::IAM::Role<br />
An IAM role for the lambda to have the necessary rights like accessing SNS for the SMS notification.</li>
</ul>
<p><img decoding="async" class="alignnone size-medium wp-image-16579" src="https://cloudar.be/wp-content/uploads/2020/03/template-650x433.png" alt="template" width="650" height="433" srcset="https://cloudar.be/wp-content/uploads/2020/03/template-650x433.png 650w, https://cloudar.be/wp-content/uploads/2020/03/template-325x217.png 325w" sizes="(max-width: 650px) 100vw, 650px" /></p>
<p>Next we code up the lambda that will call the API and send us an SMS.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-medium wp-image-16580" src="https://cloudar.be/wp-content/uploads/2020/03/code-650x433.png" alt="code" width="650" height="433" srcset="https://cloudar.be/wp-content/uploads/2020/03/code-650x433.png 650w, https://cloudar.be/wp-content/uploads/2020/03/code-1300x867.png 1300w, https://cloudar.be/wp-content/uploads/2020/03/code-325x217.png 325w" sizes="auto, (max-width: 650px) 100vw, 650px" /></p>
<p>The API provides event data for each month by just requesting the year and month in the url path like this ‘/2020-03’. So we can easily get the data for the current month and loop through its events, checking whether any are occurring the next morning. If so we receive an SMS notifying us (note that you can provide the number of your girlfriend here, but it’s not recommended as I have found out it isn’t that effective).</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-16581 size-thumbnail" src="https://cloudar.be/wp-content/uploads/2020/03/watch-325x217.jpg" alt="result" width="325" height="217" srcset="https://cloudar.be/wp-content/uploads/2020/03/watch-325x217.jpg 325w, https://cloudar.be/wp-content/uploads/2020/03/watch-650x433.jpg 650w, https://cloudar.be/wp-content/uploads/2020/03/watch-1300x867.jpg 1300w" sizes="auto, (max-width: 325px) 100vw, 325px" /></p>
<p>And that’s all folks!</p>
<p>&nbsp;</p>
<p>I’m aware that this trick is no rocket science, and that this isn’t even a full guide to get to the same result (leave a comment if you want some more details), but I thought it would be fun to share how I resolved one of life’s little problems using AWS.</p>
<p>As I’m moving toward two years of professional experience using the platform, I’m still amazed at how easily you can code some services together and create a working, scalable and highly available project in a matter of minutes or hours.</p>
<p>Hope you liked my trashy tale &#8211; keep your garages clean and your heads in the cloud!</p>
<p>The post <a href="https://cloudar.be/awsblog/lets-trash-talk/">Let&#8217;s trash talk!</a> appeared first on <a href="https://cloudar.be">Cloudar</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using Route53 to support on-demand applications</title>
		<link>https://cloudar.be/awsblog/using-route53-to-support-on-demand-applications/</link>
					<comments>https://cloudar.be/awsblog/using-route53-to-support-on-demand-applications/#respond</comments>
		
		<dc:creator><![CDATA[Ben Bridts]]></dc:creator>
		<pubDate>Tue, 22 Nov 2016 11:44:20 +0000</pubDate>
				<category><![CDATA[AWS Blog]]></category>
		<category><![CDATA[CloudFront]]></category>
		<category><![CDATA[Cost]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[Route53]]></category>
		<guid isPermaLink="false">https://cloudar.be/?p=3670</guid>

					<description><![CDATA[<p>One of the best ways to save money on AWS is turning resources off when you don&#8217;t use them. This is pretty easy to automate if you have consistent usage patterns (like an application that&#8217;s only used during business hours), but can be harder if the usage is very irregular (for example an application that&#8217;s [&#8230;]</p>
<p>The post <a href="https://cloudar.be/awsblog/using-route53-to-support-on-demand-applications/">Using Route53 to support on-demand applications</a> appeared first on <a href="https://cloudar.be">Cloudar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of the best ways to save money on AWS is turning resources off when you don&#8217;t use them. This is pretty easy to automate if you have consistent usage patterns (like an application that&#8217;s only used during business hours), but can be harder if the usage is very irregular (for example an application that&#8217;s only used a few times per quarter).</p>
<p>We recently worked with a customer that had some applications that could be without usage for months. To be more cost efficient, they were looking for a solution where:</p>
<ul>
<li>They could turn off as much instances and services as possible</li>
<li>The users could start the application with one button click if they needed to use it</li>
<li>The users didn&#8217;t have AWS credentials</li>
</ul>
<p>We came up with the following solution to satisfy these requirements, and if you&#8217;re running the same kind of applications, maybe you can also reduce costs by implementing this.</p>
<p><img loading="lazy" decoding="async" src="https://cloudar.be/wp-content/uploads/2016/11/Untitled-15.png" alt="" width="730" height="815" class="alignnone size-full wp-image-5971" srcset="https://cloudar.be/wp-content/uploads/2016/11/Untitled-15.png 730w, https://cloudar.be/wp-content/uploads/2016/11/Untitled-15-645x720.png 645w" sizes="auto, (max-width: 730px) 100vw, 730px" /></p>
<p>This solutions works by taking advantage of the Route53 health checks. We&#8217;ve split up our infrastructure in two parts: an always-on part that uses low cost or usage based services to provide the user with a way to start the real application; and a part that can started and stopped on demand.</p>
<p>We configure the on-demand part to be the primary resource in Route53 and the always-on part as a failover. This way the traffic will be routed to the real application if it&#8217;s online, and the user will get a static webpage that gives him the option to start the application if it&#8217;s not.</p>
<p>If we look at how this would go if the application is offline, these are the steps that would happen:</p>
<ol>
<li>The user requests the DNS record for application.example.com from Route53. Because the real application is offline, Route53 will respond with the recordset of the fallback CloudFront distribution.</li>
<li>The user request a page from CloudFront. CloudFront will get this from S3 and serve it to the user. This page contains an explanation of why the application is not available and a button to start it.</li>
<li>When the user clicks the button, it uses javascript to call the API Gateway and invoke a lambda function.</li>
<li>The lambda function calls Service Catalog or CloudFormation (depending on your environment) to start the real application</li>
<li>When the application has started, the health check will pass, and Route53 will start returning the recordset for the CloudFront distribution that is linked to the application</li>
<li>When the user uses the new DNS records, it will go through the second CloudFront distribution and to the real application</li>
</ol>
<p>Some things to keep in mind.</p>
<p>This only a high level overview of a possible solution. To implement this, you would also have to consider the following:</p>
<ul>
<li>After starting the Application, the static webpage should refresh the page, to force the browser to do a new DNS lookup.</li>
<li>CloudFront will cache errors for 5 minutes by default. Decreasing this will make the failover go faster.</li>
<li>The TTL of an CloudFront DNS record is 60 seconds</li>
</ul>
<p>The post <a href="https://cloudar.be/awsblog/using-route53-to-support-on-demand-applications/">Using Route53 to support on-demand applications</a> appeared first on <a href="https://cloudar.be">Cloudar</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cloudar.be/awsblog/using-route53-to-support-on-demand-applications/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
