<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>CloudFormation on Technology Enlightened</title>
    <link>https://pprakash.me/tags/cloudformation/</link>
    <description>Recent content in CloudFormation on Technology Enlightened</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>&amp;copy; &lt;a href=&#34;https://github.com/p-prakash/&#34;&gt;Prakash P&lt;/a&gt; 2015 - 2023</copyright>
    <lastBuildDate>Wed, 28 Jun 2017 08:45:47 +0000</lastBuildDate>
    <atom:link href="https://pprakash.me/tags/cloudformation/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Continuous Delivery of Nested AWS CloudFormation Stacks Using AWS CodePipeline</title>
      <link>https://pprakash.me/tech/2017/06/28/codepipeline-nested-cfn/</link>
      <pubDate>Wed, 28 Jun 2017 08:45:47 +0000</pubDate>
      <guid>https://pprakash.me/tech/2017/06/28/codepipeline-nested-cfn/</guid>
      <description>&lt;p&gt;In &lt;a href=&#34;https://aws.amazon.com/blogs/aws/codepipeline-update-build-continuous-delivery-workflows-for-cloudformation-stacks/&#34;&gt;CodePipeline Update – Build Continuous Delivery Workflows for CloudFormation Stacks&lt;/a&gt;, Jeff Barr discusses infrastructure as code and how to use &lt;a href=&#34;https://aws.amazon.com/codepipeline/&#34;&gt;AWS CodePipeline&lt;/a&gt; for continuous delivery. In this blog post, I discuss the continuous delivery of nested CloudFormation stacks using AWS CodePipeline, with &lt;a href=&#34;https://aws.amazon.com/codecommit/&#34;&gt;AWS CodeCommit&lt;/a&gt; as the source repository and &lt;a href=&#34;https://aws.amazon.com/codebuild/&#34;&gt;AWS CodeBuild&lt;/a&gt; as a build and &lt;a href=&#34;https://aws.amazon.com/about-aws/whats-new/2017/03/aws-codepipeline-adds-support-for-unit-testing/&#34;&gt;testing tool&lt;/a&gt;. I deploy the stacks using &lt;a href=&#34;http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html&#34;&gt;CloudFormation change sets&lt;/a&gt; following a &lt;a href=&#34;http://docs.aws.amazon.com/codepipeline/latest/userguide/approvals.html&#34;&gt;manual approval process&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here’s how to do it:&lt;/p&gt;&#xA;&lt;p&gt;In AWS CodePipeline, create a pipeline with four stages:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Automated Blue/Green deployment using Lambda and CloudFormation</title>
      <link>https://pprakash.me/tech/2016/05/05/automated-bluegreen-deployment-using-lambda-and-cloudformation/</link>
      <pubDate>Thu, 05 May 2016 07:42:54 +0000</pubDate>
      <guid>https://pprakash.me/tech/2016/05/05/automated-bluegreen-deployment-using-lambda-and-cloudformation/</guid>
      <description>&lt;p&gt;Blue/Green deployment is a well-known method to deploy an application without any downtime. Performing DNS switch is one of the very common techniques to achieve this. Using DNS switch has a minor issue with DNS caching which might take some time for DNS change to be propagated.&lt;/p&gt;&#xA;&lt;p&gt;Apart from DNS switch, AWS gives us two different options to switch the stacks. One is to have single ELB and swap it across auto-scaling group and another is switching the launch configuration of the auto-scaling group. Check the following presentation on various methods to achieve blue/green deployment in AWS.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Sending response back to CFN custom resource from python Lambda function</title>
      <link>https://pprakash.me/tech/2015/12/20/sending-response-back-to-cfn-custom-resource-from-python-lambda-function/</link>
      <pubDate>Sun, 20 Dec 2015 06:00:56 +0000</pubDate>
      <guid>https://pprakash.me/tech/2015/12/20/sending-response-back-to-cfn-custom-resource-from-python-lambda-function/</guid>
      <description>&lt;p&gt;CloudFormation uses a pre-signed S3 URL to receive the response back from the custom resources managed by it. There are few blue prints available for Node.js Lambda custom resources but nothing available for python yet. Hence I created this simple function which shall be used to send the response back to CFN custom resource by performing PUT request to the pre-signed S3 URL.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; requests&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;lambda_handler&lt;/span&gt;(event, context):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    responseStatus &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;SUCCESS&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    responseData &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; event[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;RequestType&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Delete&amp;#39;&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        sendResponse(event, context, responseStatus, responseData)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    responseData &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Success&amp;#39;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Test Passed.&amp;#39;&lt;/span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sendResponse(event, context, responseStatus, responseData)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;sendResponse&lt;/span&gt;(event, context, responseStatus, responseData):&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    responseBody &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Status&amp;#39;&lt;/span&gt;: responseStatus,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Reason&amp;#39;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;See the details in CloudWatch Log Stream: &amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; context&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;log_stream_name,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;PhysicalResourceId&amp;#39;&lt;/span&gt;: context&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;log_stream_name,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;StackId&amp;#39;&lt;/span&gt;: event[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;StackId&amp;#39;&lt;/span&gt;],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;RequestId&amp;#39;&lt;/span&gt;: event[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;RequestId&amp;#39;&lt;/span&gt;],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;LogicalResourceId&amp;#39;&lt;/span&gt;: event[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;LogicalResourceId&amp;#39;&lt;/span&gt;],&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Data&amp;#39;&lt;/span&gt;: responseData}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    print &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;RESPONSE BODY:n&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; json&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;dumps(responseBody)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;try&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        req &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; requests&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;put(event[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;ResponseURL&amp;#39;&lt;/span&gt;], data&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;json&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;dumps(responseBody))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; req&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;status_code &lt;span style=&#34;color:#f92672&#34;&gt;!=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;200&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            print req&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;text&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            &lt;span style=&#34;color:#66d9ef&#34;&gt;raise&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Exception&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Recieved non 200 response while sending response to CFN.&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;except&lt;/span&gt; requests&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;exceptions&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;RequestException &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; e:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        print e&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;raise&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; __name__ &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    lambda_handler(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;event&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;handler&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;rsquo;m using json module to form the response body, json module is available by default in the Lambda container. Whereas the requests module which I use to perform the http PUT request needs to be packaged along with the python script.&lt;/p&gt;</description>
    </item>
    <item>
      <title>CloudFormation parameters grouping and labelling</title>
      <link>https://pprakash.me/tech/2015/12/06/cloudformation-parameters-grouping-and-labelling/</link>
      <pubDate>Sun, 06 Dec 2015 07:16:52 +0000</pubDate>
      <guid>https://pprakash.me/tech/2015/12/06/cloudformation-parameters-grouping-and-labelling/</guid>
      <description>&lt;p&gt;Last week AWS &lt;a href=&#34;https://aws.amazon.com/about-aws/whats-new/2015/12/aws-cloudformation-adds-support-for-aws-codepipeline-aws-config-and-more/&#34;&gt;enhanced CloudFormation&lt;/a&gt; by adding new services like AWS CodePipeline, AWS Config, AWS KMS and few more; default stack limit also has been increased from 20 to 200. Among other new features they also have introduced this small but useful &lt;a href=&#34;http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-interface.html&#34;&gt;parameters grouping and labelling&lt;/a&gt; feature.&lt;/p&gt;&#xA;&lt;p&gt;Earlier all the parameters in a CFN template get listed in alphabetical order based on the logical name of the parameter. Also the parameters logical name is restricted to alphanumeric characters hence it causes some restrictions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Automated cross account DNS management through CFN and API access through API gateway</title>
      <link>https://pprakash.me/tech/2015/11/27/automated-cross-account-dns-management-through-cfn-and-api-access-through-api-gateway/</link>
      <pubDate>Fri, 27 Nov 2015 09:57:13 +0000</pubDate>
      <guid>https://pprakash.me/tech/2015/11/27/automated-cross-account-dns-management-through-cfn-and-api-access-through-api-gateway/</guid>
      <description>&lt;p&gt;It’s a general best practice to manage all DNS entries in Route53 in a centralized AWS account. In that case it is difficult to automate the DNS record creation/deletion based on resources created in another AWS account using CloudFormation. CloudFormation doesn’t yet have the capability to create resources in a different AWS account.&lt;/p&gt;&#xA;&lt;p&gt;Combining IAM role delegation, AWS Lambda &amp;amp; CFN Custom resources provides us a solution. I have extended the same solution by exposing the Lambda function through API gateway which provides a powerful mechanism. The illustration give below explains the solution.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Obtain AMI Id from name to be used in CFN</title>
      <link>https://pprakash.me/tech/2015/11/22/obtain-ami-id-from-ami-name-to-be-used-in-cfn/</link>
      <pubDate>Sun, 22 Nov 2015 17:41:24 +0000</pubDate>
      <guid>https://pprakash.me/tech/2015/11/22/obtain-ami-id-from-ami-name-to-be-used-in-cfn/</guid>
      <description>&lt;p&gt;In most cases we create custom AMI’s for various reasons like OS hardening, installing and configuring additional software, etc. If you use single AWS account to create the AMI’s and share it with other AWS accounts and use that as part of CloudFormation template, it is required to pass the new AMI Id every time.&lt;/p&gt;&#xA;&lt;p&gt;AWS Lambda comes handy for easy and elegant solution to get the latest AMI Id based on the AMI name and owner.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Best editor for AWS CloudFormation template (JSON)</title>
      <link>https://pprakash.me/tech/2015/11/06/best-editor-for-aws-cloudformation-template-json/</link>
      <pubDate>Fri, 06 Nov 2015 21:56:03 +0000</pubDate>
      <guid>https://pprakash.me/tech/2015/11/06/best-editor-for-aws-cloudformation-template-json/</guid>
      <description>&lt;p&gt;AWS CloudFormation template is a way to describe the AWS resources that can be created/updated/deleted and it’s in JSON format. Like many other programming languages most of the editors/IDE don’t have proper syntax highlighting for JSON.&lt;/p&gt;&#xA;&lt;p&gt;For a long time I was using &lt;a href=&#34;https://notepad-plus-plus.org/&#34;&gt;notepad++&lt;/a&gt; and the built-in Javascript syntax highlighting which doesn&amp;rsquo;t provide much granular highlighting. I was looking for a much better editor and finally found &lt;a href=&#34;https://atom.io/&#34;&gt;Atom&lt;/a&gt;, the most powerful editor by GitHub. It provides the ability to customize almost everything in it. It also can be extended using huge list of packages and themes.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
