<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tushar Babbar on Medium]]></title>
        <description><![CDATA[Stories by Tushar Babbar on Medium]]></description>
        <link>https://medium.com/@tusharbabbar?source=rss-955ddeb11eac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_3dXLasnRDykWxm7GJ5RyQ.jpeg</url>
            <title>Stories by Tushar Babbar on Medium</title>
            <link>https://medium.com/@tusharbabbar?source=rss-955ddeb11eac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:41:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tusharbabbar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AES GCM — Encrypt in Java, decrypt in Ruby]]></title>
            <link>https://medium.com/@tusharbabbar/aes-gcm-encrypt-in-java-decrypt-in-ruby-f7f5980205b2?source=rss-955ddeb11eac------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7f5980205b2</guid>
            <category><![CDATA[gcm]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ea]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Tushar Babbar]]></dc:creator>
            <pubDate>Fri, 15 Nov 2019 10:19:20 GMT</pubDate>
            <atom:updated>2019-11-15T10:33:49.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>AES GCM — Encrypt in Java, decrypt in Ruby</h3><p>AES GCM implementation in Java abstracts the need to share the auth_tag and appends it to the encrypted data. The doFinal method returns cipher text that can be directly fed to the decrypt cipher along with key and iv .</p><p>Ruby implementation is more explicit. After encryption auth_tag can be retrieved which has to be set in the decrypt cipher.</p><p>Thus, extract out the auth_tag from the end of the Java encrypted text and feed that to the Ruby decrypt cipher.</p><p><strong>Java encryption</strong></p><pre>public static final int AES_KEY_SIZE = 256;<br>public static final int GCM_IV_LENGTH = 12;<br>public static final int GCM_TAG_LENGTH = 16;</pre><pre>SecretKey key = keyGenerator.generateKey();<br>byte[] IV = new byte[GCM_IV_LENGTH];<br>SecureRandom random = new SecureRandom();<br>random.nextBytes(IV);</pre><pre>// Create SecretKeySpec<br>SecretKeySpec keySpec = new SecretKeySpec(key.getEncoded(), &quot;AES&quot;);</pre><pre>// Create GCMParameterSpec<br>GCMParameterSpec gcmParameterSpec = new GCMParameterSpec(16 * 8, IV);</pre><pre>// Initialize Cipher for ENCRYPT_MODE<br>cipher.init(Cipher.ENCRYPT_MODE, keySpec, gcmParameterSpec);</pre><pre>// Perform Encryption<br>byte[] cipherText = cipher.doFinal(plaintext);</pre><p><strong>Ruby decryption</strong></p><pre>cipher_text = Base64.decode64 b64_cipher_text</pre><pre># Extract the auth_tag. auth_tag_length = 16.<br>cipher_text_with_auth_tag = enc_data.unpack(&quot;C*&quot;)cipher_text = cipher_text_with_auth_tag[0..-17].pack(&quot;C*&quot;)<br>auth_tag = cipher_text_with_auth_tag.last(16).pack(&quot;C*&quot;)</pre><pre># Initializing with 256. This seems to work with <br># 128 byte configuration in Java<br>cipher = OpenSSL::Cipher.new (&quot;aes-256-gcm&quot;)</pre><pre># Key and iv should be Hex strings.<br>cipher.decrypt<br>cipher.padding = 0<br>cipher.key = key<br>cipher.iv = iv<br>cipher.auth_tag = auth_tag</pre><pre>plain_text = cipher.update(cipher_text) + cipher.final</pre><p><strong>Glossary</strong></p><p><a href="https://www.aes-gcm.com/">What is AES GCM?</a></p><p><a href="https://crypto.stackexchange.com/questions/17999/aes256-gcm-can-someone-explain-how-to-use-it-securely-ruby">Explains how AES GCM works. [In the most voted answer]</a></p><p><a href="https://stackoverflow.com/questions/23864440/aes-gcm-implementation-with-authentication-tag-in-java">Java auth tag abstraction explained</a></p><p><a href="https://github.com/ruby/openssl/issues/63">How to decrypt using AES GCM in ruby explained</a></p><p><a href="https://blog.bigbinary.com/2011/07/20/ruby-pack-unpack.html">Ruby string manipulation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7f5980205b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essence of linear algebra [video lecture series notes]]]></title>
            <link>https://medium.com/@tusharbabbar/essence-of-linear-algebra-video-lecture-series-notes-52d573066b69?source=rss-955ddeb11eac------2</link>
            <guid isPermaLink="false">https://medium.com/p/52d573066b69</guid>
            <dc:creator><![CDATA[Tushar Babbar]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 09:21:10 GMT</pubDate>
            <atom:updated>2019-08-05T09:21:10.036Z</atom:updated>
            <content:encoded><![CDATA[<p>This post contains notes of what I understood and captured from the video lecture series by 3Blue1Brown. <a href="https://www.youtube.com/watch?v=kjBOesZCoqc&amp;list=PL_w8oSr1JpVCZ5pKXHKz6PkjGCbPbSBYv&amp;index=1"><em>Link to the lecture series</em></a></p><h3>Vectors, what even are they? (Chapter 1)</h3><p>Building blocks of linear algebra.</p><p>For physicists, vectors are arrows pointing in a given direction and with a certain length. Moving the vector in the space does not have any implication on the vector for a student of physics.</p><p>For computer scientists, vectors are ordered list of numbers. So let’s say we want to represent the price of the houses based on their size, we can use a 2-dimensional vector with one dimension as size and other as price. Thus a vector is just a list of numbers for computers.</p><p>So, henceforth we should visualize a vector as an arrow in the 2d plane with its root at the (0,0).</p><p>Vectors v/s scalers. So, in general, we read about scalers and vectors. Vectors are those with direction and scalars are normal numbers without direction. Actually, this term is coming from the Scaling operation. When you multiply a number with a vector it scales the vector. So, if you multiply 2 with a vector it scales the length of the vector to be double. Thus due to this scaling operation, all numbers are also referred to as scalars.</p><p>Mathematicians are interested in the operations that are performed on the vectors — Vector Addition and Scalar multiplication.</p><h3>Linear combinations, span, and basis vectors (Chapter 2)</h3><p>Vector Coordinates — Each vector (in a 2D vector space) is a sum of 2 scaled vectors. These 2 vectors form the basis of that coordinate system. The (popular) `<em>xy` </em>coordinate system has 2 basis vectors<em> i_hat (1, 0) </em>and <em>j_hat (0, 1)</em>. <em>i_hat </em>has magnitude 1 in the direction of the `x` axis. <em>j_hat </em>has magnitude 1 in the direction of the `y` axis. Thus any vector [2, 3] can be represented as a sum of 2 scaled vectors 2 * <em>i_hat </em>+ 3 * <em>j_hat </em>.</p><p>Thus the vector coordinates can be thought of as scalers that scale the basis vectors of that coordinate system.</p><p>Basis Vectors — Any set of 2 vectors can be chosen as the basis vectors of a new coordinate system and any vector can be represented as a vector in that coordinate system. (given the condition that the 2 chosen vectors are not 0 and non-coinciding.)</p><p>Span — The span of 2 vectors is defined by all the vectors that can be reached by the linear sum of any scaled combination of these 2 vectors. (This is all vectors for most pairs of 2 vectors you chose, except when vectors are coinciding, in that case, all vectors resulting from these 2 vectors will lie on the same line. And, when the magnitude of the vectors is 0)</p><blockquote>The basis vectors of a vector space is a set of linearly independent vectors that span the full space.</blockquote><h3>Linear transformations and matrices (Chapter 3)</h3><p>Transformations — Transformations are functions. Given an input, a function transforms it based on the transformation it defines. In terms of Linear Algebra, transformations deal with vectors as inputs. These are called transformations instead of a function because in case of vectors we can visualize the change in the input vector in the vector space. If we consider the complete vector space as an input to the transformation function we can visualize the changes on the whole vector space (this is explained better in the video).</p><p>Linear Transformations — In Linear Algebra we deal with an only specific type of transformations i.e. Linear Transformations. In Linear Transformations, the transformation does not move the origin and the grid lines remain parallel and evenly spaced.</p><p>We can think of a 2x2 matrix as a transformation of the space, with the first column representing the transformation on the vector <em>i_hat</em> and the second as a transformation on the vector <em>j_hat. </em>This way we can see matrix multiplication as the transformation happening on any given vector. This notion of the relation between linear transformation with matrices helps us to understand the further advanced topics.</p><h3>Matrix multiplication as composition (Chapter 4)</h3><h3>Three-dimensional linear transformations (Chapter 5)</h3><h3>The determinant (Chapter 6)</h3><p>Transformation of the vector space leads to change in the area of the unit square created by the basis of the vector space. The factor of changes introduced by the transformation is defined as the Determinant of a transformation.</p><p>The determinant can be negative as well. This would mean the flipping of the space after the transformation.</p><p>Quiz — <em>Explain in a sentence, det(M1M2) = det(M1)det(M2)</em></p><p>The amount of transformation suffered by a vector V after applying M2 and then M1 would be the same as applying the product of M1M2, thus the change in the area would also be the same.</p><h3>Inverse matrices, column space and null space (Chapter 7)</h3><p>Linear algebra helps us to solve the linear system of equations i.e. where the variables have the power of 1. This type of equations system can be expressed with a matrix multiplication between a linear transformation (represented by coefficient matrix) and a vector (represented by the variables), the result of all these equations can be then represented as a vector which is the result of such a multiplication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rRWg5s3PCA_l1EY-4sWyVw.png" /><figcaption>Image from inside the video</figcaption></figure><p>Inverse Matrix — Thus understanding the above equation we can say that the transformation `<em>A`, </em>when applied on vector `<em>x`, </em>results in vector `v`. Let’s say if the applied transformation changed the identity vector `<em>j_hat` </em>from (0, 1) to (1, 1) there could be another transformation that will result in moving the vector (1, 1) back to (0, 1). This transformation that nullifies the effect of `<em>A</em>` is called `<em>A_inverse`.</em></p><p><em>`A_inverse</em>` does not exist for any matrix whose determinant is 0.</p><p>Rank of a matrix — The number of dimensions in the output of a transformation.</p><h3>Nonsquare matrices as transformations between dimensions (chapter 8)</h3><p>Non squared matrix multiplication can be visualized similarly as the square matrix multiplication. In the non-squared multiplication will lead to a transformation of a vector into space with different dimensions.</p><h3>Dot products and Duality (chapter 9)</h3><p>Dot products — Projecting a vector on another vector. Also, transforming a vector to another vector.</p><p><em>(x, y).(p, q) = x*p + y*q</em></p><p>Which is same as applying transformation `<em>(x, y)</em>` on a vector `<em>(p, q)</em>`.</p><h3>Eigenvectors and eigenvalues (chapter 14)</h3><p>Any matrix can be considered as a `Transformation` of a vector space. Applying this transformation on a special vector in the vector space can lead to a transformation such that the vector remains to be on the span of the vector in the original vector space. Thus the resulting transformation applied on the vector is like a scalar multiplication to the vector. Hence the formula</p><p><em>A*v = λv.</em></p><p>Where λ is a scalar and an eigenvalue for the matrix.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52d573066b69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Compiled, Interpreted or Both?]]></title>
            <link>https://medium.com/@tusharbabbar/compiled-interpreted-or-both-ec801eaeebff?source=rss-955ddeb11eac------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec801eaeebff</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tushar Babbar]]></dc:creator>
            <pubDate>Fri, 05 Jul 2019 09:15:03 GMT</pubDate>
            <atom:updated>2019-07-05T09:15:03.846Z</atom:updated>
            <content:encoded><![CDATA[<p>I had a general misconception that “compiled languages are more performant because they are compiled and not interpreted”. I went on and asked some of my team members to validate if the notion is generic enough — <strong>It is!</strong>. Here’s what I discovered.</p><blockquote>Sources:</blockquote><blockquote><a href="https://nedbatchelder.com/blog/201803/is_python_interpreted_or_compiled_yes.html">is_python_interpreted_or_compiled_yes</a></blockquote><blockquote><a href="https://stackoverflow.com/questions/441824/java-virtual-machine-vs-python-interpreter-parlance">java-virtual-machine-vs-python-interpreter-parlance</a></blockquote><blockquote><a href="https://www.oreilly.com/library/view/java-performance-the/9781449363512/ch04.html">Java Performance: Chapter 4</a></blockquote><h3>Commentary</h3><p>Both CPython and Java are compiled and interpreted languages. The difference in performance is due to static vs. dynamic typing.</p><p>Both the languages first are compiled to an intermediate bytecode that can be interpreted by a process virtual machine (Unlike C that gets compiled to CPU instructions directly). The CPython virtual machine is able to interpret the python bytecode to CPU instructions set and in case of Java bytecode, it’s the JVM that does the job.</p><p>In JVM the default method to parse the bytecode is interpretation while to enhance the program performance JIT (just in time) compilation is introduced. Based on the runtime execution of the program the Java virtual machine collects metrics to decide which part of the code it should keep a compiled copy of so that it does not have to interpret it the next time this code is executed (think about loops, same code will be interpreted multiple times, while we can keep a compiled instruction set of the code and execute it the subsequent times; also, look out for <a href="https://www.oreilly.com/library/view/java-performance-the/9781449363512/ch04.html">Hotspot Compilation</a>).</p><p>Python has a similar kind of implementation done by the PyPy project, which uses a JIT compilation to outperform CPython.</p><p>Thus they are both compiled and interpreted, the difference in performance is due to the overhead of deducing the type of a variable at runtime. The added context of the data types at the time of interpreting does the magic for Java making it more performant. Most modern languages use different techniques to achieve performance and other features like platform independence. The links shared here are highly enlightening, so if this post caught your attention do go through them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec801eaeebff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blue Green Deployment on Amazon AWS.]]></title>
            <link>https://medium.com/practo-engineering/blue-green-deployment-on-amazon-aws-38b820518411?source=rss-955ddeb11eac------2</link>
            <guid isPermaLink="false">https://medium.com/p/38b820518411</guid>
            <category><![CDATA[continuous-deployment]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tushar Babbar]]></dc:creator>
            <pubDate>Mon, 22 May 2017 08:04:28 GMT</pubDate>
            <atom:updated>2017-07-21T20:11:07.840Z</atom:updated>
            <content:encoded><![CDATA[<h3>Blue Green Deployment</h3><h4>Using Amazon AWS and Python.</h4><h3>Introduction to components</h3><p>In <a href="https://martinfowler.com/bliki/BlueGreenDeployment.html">Blue green deployment approach</a> we create replica of the current production infrastructure and route all the traffic to the replica. The current infrastructure is termed as <strong>Blue</strong> while the replica is <strong>Green</strong>. Of course we make all code updates in the green fleet. This ensure high availability during deployments.</p><p>This article is about implementing blue green deployment using Amazon AWS and Python. We will use <a href="https://aws.amazon.com/ec2/?nc2=h_m1">Elastic Compute Cloud(EC2)</a>, <a href="https://aws.amazon.com/autoscaling/">Autoscaling Groups</a>, <a href="http://docs.aws.amazon.com/autoscaling/latest/userguide/LaunchConfiguration.html">Launch Configurations(LC)</a>, <a href="https://aws.amazon.com/elasticloadbalancing/?nc2=h_m1">Elastic Load Balancer(ELB)</a>, <a href="https://aws.amazon.com/route53/?nc2=h_m1">Route 53</a>, <a href="http://boto.cloudhackers.com/en/latest/">Python Boto</a> and <a href="http://www.fabfile.org/">Python Fabric</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C5_IVHuyT5hRrmALI-lSEw.png" /><figcaption>Fleet of application instances behind ELB, managed by ASG.</figcaption></figure><p>Our infrastructure contains a fleet of EC2 instances behind an ELB managed by an ASG. Route 53 acts as a gateway for users to interact with our service. All traffic to our domain reaches the ELB which distributes the load to the EC2 instances. ASG manages our cluster of instances. ASG can add an instance or remove it based on the configurable policies. ASG use <a href="http://docs.aws.amazon.com/autoscaling/latest/userguide/LaunchConfiguration.html">Launch Configurations (LC)</a> and <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html">Amazon Machine Images (AMI)</a>. Launch configurations define which virtual image(AMI) to use while scaling out.</p><p>Python Boto and Fabric are being used to automate the process of deployments. Boto is a library to access Amazon AWS via python scripts. An alternative to Boto is <a href="https://aws.amazon.com/cli/">Amazon AWS CLI</a>. Fabric is another python library that comes handy to run deployment tasks on remote servers via SSH (concurrently!).</p><h3>Talk is cheap, show me the CODE!</h3><p>There can be two approaches to implement blue green deployments.</p><ol><li>We can replace the blue(exiting) EC2 instance with green(with latest code) EC2 instances. In this approach, we create the same amount of instance in the existing infrastructure, update the instances with new code and add them behind the load balancer and kill blue instances.</li><li>Or, we can make the switch on DNS level using Route 53. In this approach we create an exact replica of our infrastructure with updated code i.e. a new ASG, new ELB and new set of instances that will contain the latest code.</li></ol><p>In the next section we give implementation details for both the approaches.</p><h4>Approach 1</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wUCM4XlotIUbdn5iIPV0ZQ.png" /><figcaption>Add green instances code behind ELB and terminate blue instances.</figcaption></figure><p><em>Step 1.</em> We get the details of the production ASG. We define a function describe_asg which takes the name of the ASG and gets details using Boto.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff32e6a44b2b2d4d8b8757cbe7fa7cf6/href">https://medium.com/media/ff32e6a44b2b2d4d8b8757cbe7fa7cf6/href</a></iframe><p><em>Step 2. </em>Using asg_details we can get the number of instances and also the LC name. We use LC name to describe details like AMI id, instance type etc. Now we spun off instances with exact same configuration. We will update these instances with latest code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b14a925a5b986a5faf3e194674560c5d/href">https://medium.com/media/b14a925a5b986a5faf3e194674560c5d/href</a></iframe><p><em>Step 3. </em>We use Python Fabric to update code in new instances. With Fabric we define task to run on remote machines. We use env.rolesdef to define machine roles. Any task attached to a role will only be executed in a machine with same role. Here we are defining deployment role. We will add all new instances to this role. We can define tasks like update_code , validate_service etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5a339007c2d901fe1f86ff788d13ad6/href">https://medium.com/media/c5a339007c2d901fe1f86ff788d13ad6/href</a></iframe><p><em>Step 4.</em> Now that we have the latest revision of code available in the deployment instances we need to bake an image. This image will be used by the ASG in case of a scale out. AWS provides a way to create image without the need for a server to reboot. We are using this option so that we don’t need to wait for service to be up and running before we attach it to the ASG in next steps.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70d754f3cb04dbbcbd9d8d667dcdee34/href">https://medium.com/media/70d754f3cb04dbbcbd9d8d667dcdee34/href</a></iframe><p><em>Step 5.</em> Now we have to attach the deployment instances to the ASG and ELB and terminate all the old instances. We have to attach the instances to ASG first and then to ELB as this is a precondition for ELB. While attaching the the ASG we may have to increase the max capacity of instances ASG can increase to scale out. When we attach the instances to ASG it increases the desired capacity. ASG throws an error if we try to add more instances than the max capacity. Also, we must check that instances in ELB pass health checks i.e. they are in service. If instances are not in service it indicates that some error has occurred and the deployment should <strong>fail</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5822273843293bb51784b6b1a675732/href">https://medium.com/media/a5822273843293bb51784b6b1a675732/href</a></iframe><p><em>Step 6.</em> If <em>Step 5. </em>succeeds we can now update the ASG to use the new image to spun off new instances. To update the ASG we will have to create a new LC which will be an updated copy of the old LC. We replace the image id with the newly formed AMI and attach new LC to the ASG.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6ae29444bdb79427647546eb2a0851b/href">https://medium.com/media/d6ae29444bdb79427647546eb2a0851b/href</a></iframe><p><em>Step 7.</em> If all the above steps succeed then we will have a set of instances with old code and a set with new code. Now we need to terminate the old instances.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e693a078b3662978ab404e200eea8fcf/href">https://medium.com/media/e693a078b3662978ab404e200eea8fcf/href</a></iframe><p>So, we have replaced the infrastructure with new code successfully.</p><h4>Approach 2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RlCC1IC8QcmKN79y5sW9lA.png" /><figcaption>Create exact replica of the Blue ASG and switch traffic to it using Route 53.</figcaption></figure><p>This approach is a simpler one as we depend on Amazon ASG to create the instances and attach them to the ELB. All we got to do is create an AMI with updated code and create an ASG.</p><p>To create and AMI with updated code we can follow the <em>Step 1, 2, 3 and 4 </em>of <strong>Approach 1</strong>. Note that in <em>Step 2 </em>we don’t need to create an exact number of instances we just need to create an AMI using only one deployment instance. Once that is done we may terminate the deployment instance using <em>Step 7 </em>of <strong>Approach 1</strong>.</p><blockquote>Creating ASG Replica</blockquote><p><em>Step 1. </em>First up we create a new LC using copy_lc_with_new_ami. We use the AMI with updated code in this LC.</p><p><em>Step 2. </em>Now we create a new ELB that we will attach to the new ASG. This ELB has to be configured exactly as the older one. So we will copy the listeners, security_groups, subnets and health_checks .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14f8897ae1f1e5e8aaea9c2328eba4ca/href">https://medium.com/media/14f8897ae1f1e5e8aaea9c2328eba4ca/href</a></iframe><p><em>Step 3. </em>We create a new ASG using the newly created ELB and Launch configuration. We use check_instances_in_service to validate success of this step.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a0d44c766e172cd61c9ed84077513b0/href">https://medium.com/media/6a0d44c766e172cd61c9ed84077513b0/href</a></iframe><p>In order for ASG to scale in/out we need to <a href="http://docs.aws.amazon.com/autoscaling/latest/userguide/policy_creating.html#policy-updating-console">configure the scaling policies</a>. This can be done using AWS Cloudwatch Alarms and Simple Scaling Policies. So, we create a cloudwatch alarm which can monitor a metric and notify the scaling policy to perform the desired action.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbbd52fb2dc2421a0aea29c5452758de/href">https://medium.com/media/dbbd52fb2dc2421a0aea29c5452758de/href</a></iframe><p><em>Step 4. </em>Now that ASG is set up and there are instances ready to serve traffic behind the new ELB last step is to switch the traffic using Route53. We will create an A record entry in Route53 to redirect all traffic to our desired domain to reach to green ELB’s DNS.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0ac9ff79bf67eb51b7966caba3940f8/href">https://medium.com/media/b0ac9ff79bf67eb51b7966caba3940f8/href</a></iframe><p><em>Step 5. </em>As traffic is now being served by the Green ASG we do not need the Blue one. We will set the minimum capacity of Blue ASG to zero. This will scale down the Blue ASG gracefully.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3010ff5c98d038d090845b96048f486/href">https://medium.com/media/e3010ff5c98d038d090845b96048f486/href</a></iframe><p>Thus we have successfully updated our infrastructure in Blue Green Approach. We can delete the Blue ASG(old) once sanity of the Green ASG has been ensured.</p><p>Follow us on <a href="https://twitter.com/practodev">twitter</a> for regular updates. If you liked this article, please hit the ❤ button to recommend it. This will help other Medium users find it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38b820518411" width="1" height="1" alt=""><hr><p><a href="https://medium.com/practo-engineering/blue-green-deployment-on-amazon-aws-38b820518411">Blue Green Deployment on Amazon AWS.</a> was originally published in <a href="https://medium.com/practo-engineering">Practo Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>