<?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>cloudformation Archives | Cloudar</title>
	<atom:link href="https://cloudar.be/tag/cloudformation/feed/" rel="self" type="application/rss+xml" />
	<link>https://cloudar.be/tag/cloudformation/</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>Validate ACM certificates in Cloudformation</title>
		<link>https://cloudar.be/awsblog/validate-acm-certificates-in-cloudformation/</link>
		
		<dc:creator><![CDATA[Michiel Vanderlinden]]></dc:creator>
		<pubDate>Wed, 08 Jan 2020 08:03:21 +0000</pubDate>
				<category><![CDATA[AWS Blog]]></category>
		<category><![CDATA[acm]]></category>
		<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[automatically validate acm]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[cloudformation]]></category>
		<category><![CDATA[custom resource]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://www.cloudar.be/?p=16482</guid>

					<description><![CDATA[<p>Intro: We will use a custom resource written in Python that will be able to create ACM certificates with DNS validation. The custom resource will also automatically validate this certificate if the validation domain is managed by a Route53 hosted zone. We will also be able to specify an AWS region to create the certificate [&#8230;]</p>
<p>The post <a href="https://cloudar.be/awsblog/validate-acm-certificates-in-cloudformation/">Validate ACM certificates in Cloudformation</a> appeared first on <a href="https://cloudar.be">Cloudar</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3>Intro:</h3>
<p>We will use a custom resource written in Python that will be able to create ACM certificates with DNS validation. The custom resource will also automatically validate this certificate if the validation domain is managed by a Route53 hosted zone. We will also be able to specify an AWS region to create the certificate in, this region is independent of the Cloudformation stack region which for example makes it possible to deploy a certificate in region us-east-1 (to use with cloudfront) while deploying the stack in region eu-west-1. The resource will also provide the certificate arn as an output parameter so it can be used by other resources in the stack. Lastly when you delete the custom resource it will cleanup all validation records and the certificate itself.</p>
<h3>Requirements:</h3>
<ul>
<li>Python3</li>
<li>Pip</li>
<li>Bash</li>
<li>Zip</li>
<li>An S3 bucket to deploy the custom resource package on</li>
<li>A hosted zone for the validation record</li>
</ul>
<h3>Implementation:</h3>
<p>Let&#8217;s get started by downloading all the required code from our <a href="https://github.com/WeAreCloudar/cloudar_acm_plus">GitHub repository.</a></p>
<h4>Step1: Uploading the custom resource package</h4>
<p>In this step we are going to prepare the custom resource package and upload it to an S3 bucket.</p>
<p>First we go into the custom resource directory.<br />
<code>cd cloudar-acm-plus-custom-resource</code></p>
<p>Next we execute a script to install all required dependencies.<br />
<code>sh install_dependencies</code></p>
<p>Now we are ready to create the package.<br />
<code>sh pack_custom_resource</code></p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-16487 " src="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_package_commands.png" alt="package commands" width="595" height="378" srcset="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_package_commands.png 1120w, https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_package_commands-768x488.png 768w" sizes="auto, (max-width: 595px) 100vw, 595px" /></p>
<p>You will now find the zipfile &#8216;cloudar-acm-plus-custom-resource.zip&#8217; in &#8216;cloudar-acm-plus-custom-resource/packed&#8217;, upload this zip file to your S3 bucket.</p>
<h4>Step2: Creating a Cloudformation template</h4>
<p>Now we can create a Cloudformation template in which we use this custom resource to create an ACM certificate.<br />
You can use the template &#8216;cfn.yaml&#8217; as an example.</p>
<p>First create a Lambda resource as following<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-16492 " src="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_cfn_lambda.png" alt="auto validate lambda" width="520" height="475" srcset="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_cfn_lambda.png 1042w, https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_cfn_lambda-768x702.png 768w, https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_cfn_lambda-788x720.png 788w" sizes="auto, (max-width: 520px) 100vw, 520px" /></p>
<p>Use the name of your bucket for the property &#8216;S3Bucket&#8217; .</p>
<p>Next we create the custom resource.<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-16493 " src="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_cfn_cr.png" alt="auto validate cfn cr" width="454" height="287" srcset="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_cfn_cr.png 832w, https://cloudar.be/wp-content/uploads/2020/01/auto_validate_cfn_cr-768x486.png 768w" sizes="auto, (max-width: 454px) 100vw, 454px" /></p>
<p>We can set the following properties here:</p>
<ul>
<li>DomainName: (REQUIRED type:String) The domain name for the acm certificate.</li>
<li>AdditionalDomains: (OPTIONAL type:List) Additional domains for the acm certificate</li>
<li>ValidationDomain: (REQUIRED type:string) The domain name for the validation domain of the acm certificate</li>
<li>HostedZoneId: (REQUIRED type:string) The hosted zone id for the validation domain of the acm certificate</li>
<li>CertificateRegion: (REQUIRED type:string) The region to deploy the acm certificate in</li>
<li>IdempotencyToken: (REQUIRED type:string pattern: \w+) The idempotency token for the create call of the acm certificate doc: <a href="https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html#ACM-RequestCertificate-request-IdempotencyToken" rel="nofollow">https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html#ACM-RequestCertificate-request-IdempotencyToken</a></li>
<li>CertificateTags: (OPTIONAL type:list) The tags for the acm certificate</li>
</ul>
<p>In order for the DNS record cleanup and delete certificate functionality to work when you delete the Cloudformation stack it is important to set the following output.<br />
<img loading="lazy" decoding="async" class="alignnone wp-image-16495 " src="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_cfn_output.png" alt="auto validate cfn output" width="666" height="98" srcset="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_cfn_output.png 1238w, https://cloudar.be/wp-content/uploads/2020/01/auto_validate_cfn_output-768x113.png 768w" sizes="auto, (max-width: 666px) 100vw, 666px" /></p>
<p>As you can see we can access the arn of the certifcate created by the custom resource with the GetAtt function on the resource.<br />
<code>!GetAtt CreateCertificateCustomResource.certificate_arn</code></p>
<h4>Step3: Deploy the cloudformation</h4>
<p>Finally the only thing left to do is deploy the Cloudformation template.<br />
Once the deploy is started Cloudformation will create the Lambda containing the code from step1 and start a custom resource which will create the certificate and validation records. Once the status of the certificate becomes &#8216;ISSUED&#8217; the custom resource will finish successfully and report the arn of the certificate back to Cloudformation. We can now further use this arn in other resources in the Cloudformation template.<br />
When you delete the Cloudformation stack, the custom resource will cleanup the validation records in the hosted zone and delete the certificate.</p>
<p>CREATE_COMPLETE</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-16496 size-full" src="https://cloudar.be/wp-content/uploads/2020/01/auto_validate_acm_icon.png" alt="auto validate acm icon" width="300" height="259" /></p>
<p>The post <a href="https://cloudar.be/awsblog/validate-acm-certificates-in-cloudformation/">Validate ACM certificates in Cloudformation</a> appeared first on <a href="https://cloudar.be">Cloudar</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
