<?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 Arnaldo Garat on Medium]]></title>
        <description><![CDATA[Stories by Arnaldo Garat on Medium]]></description>
        <link>https://medium.com/@arnaldo.garat?source=rss-7c8952185e8f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eCg6CvFZOlIV9st5.jpg</url>
            <title>Stories by Arnaldo Garat on Medium</title>
            <link>https://medium.com/@arnaldo.garat?source=rss-7c8952185e8f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 11:03:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arnaldo.garat/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[Updating instances in a GCP Managed Instance Group with Terraform]]></title>
            <link>https://medium.com/@arnaldo.garat/updating-instances-in-a-gcp-managed-instance-group-with-terraform-d2b15a533499?source=rss-7c8952185e8f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2b15a533499</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[rolling-updates]]></category>
            <category><![CDATA[managed-instance-group]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Arnaldo Garat]]></dc:creator>
            <pubDate>Wed, 09 Oct 2019 15:47:16 GMT</pubDate>
            <atom:updated>2019-10-09T15:55:02.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ulpB_AQqTGJ4P31PowCPkQ.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@goumbik?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Lukas</a> from <a href="https://www.pexels.com/photo/code-coding-computer-data-574077/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p>Managed Instance Groups (MIG) are collections of compute instance that you manage as a single entity.</p><p>It’s relatively easy to create one with <strong>Terraform</strong>, you just need to describe a <a href="https://www.terraform.io/docs/providers/google/r/compute_instance_template.html"><strong>compute instance template</strong></a> and the<a href="https://www.terraform.io/docs/providers/google/r/compute_region_instance_group_manager.html"> <strong>instance group manager</strong></a><strong> </strong>(note: we are using the regional instance group manager in this example):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3708304acd758d9075b63b6a8e1cb84/href">https://medium.com/media/a3708304acd758d9075b63b6a8e1cb84/href</a></iframe><p>The problem is that when you already have live infrastructure and want to change something in the template (for example, changing the machine_type from &quot;n1-standard-1&quot;to &quot;n1-standard-2&quot;), the running instances will not be automatically replaced. New instances will be created with the new template if you resize your MIG, or if you perform a rolling update, but the <strong>running instances will remain the same</strong> if you just execute terraform apply</p><p>In order to force a <strong>rolling update</strong> with terraform, we are going to introduce some randomness in the names, so when something changes in the template, the MIG is recreated, and therefore, the instances are recreated as well. Since the <strong>compute instance templates</strong> are created with a <strong>suffix</strong> that changes every time we create a new one, we are going to reference that in the name of the <strong>MIG.</strong> We are also adding the lifecycle create_before_destroy to ensure that our new instances are created before the current MIG is destroyed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1742a4c63b6bc6889ebb75f6cf0639e/href">https://medium.com/media/f1742a4c63b6bc6889ebb75f6cf0639e/href</a></iframe><p>With this simple workaround, we can automatically replace our old instances with new ones, without any manual intervention.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2b15a533499" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>