<?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 Arko Chakraborti on Medium]]></title>
        <description><![CDATA[Stories by Arko Chakraborti on Medium]]></description>
        <link>https://medium.com/@arkoprabho-chakraborti?source=rss-8d6fa3d84ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zp-AfgQ1vZ-aWS_Hgcaotw.jpeg</url>
            <title>Stories by Arko Chakraborti on Medium</title>
            <link>https://medium.com/@arkoprabho-chakraborti?source=rss-8d6fa3d84ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:32:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arkoprabho-chakraborti/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[Terraform Zero to Hero: Part 1 Variables]]></title>
            <link>https://medium.com/technogise/terraform-zero-to-hero-part-1-variables-f405c2db47b3?source=rss-8d6fa3d84ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/f405c2db47b3</guid>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Arko Chakraborti]]></dc:creator>
            <pubDate>Tue, 05 Oct 2021 04:26:54 GMT</pubDate>
            <atom:updated>2021-11-27T07:24:12.184Z</atom:updated>
            <content:encoded><![CDATA[<p>In the previous article of this series — Part 0 — we briefly went through the basics of Terraform. You can check it out <a href="https://medium.com/technogise/terraform-zero-to-hero-part-0-e5bf0429f7d6"><strong>here</strong></a> and its accompanying video <a href="https://youtu.be/Y9_xVindlXk"><strong>here</strong></a>.<br>In this article, we will take a deeper look at <strong>variables</strong> in Terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/0*U1us6ZFxU7o7Tnhg.png" /></figure><p>We have 3 types of variables:</p><ol><li><strong>Input variables</strong>: Sends values to Terraform.</li><li><strong>Output variables</strong>: Retrieves values from Terraform.</li><li><strong>Local variables</strong>: Assigns names to an expression.</li></ol><h3><strong>Input Variables</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dresource%252520%252522random_string%252522%252520%252522random_sixteen%252522%252520%25257B%25250A%252520%252520length%252520%252520%25253D%25252016%25250A%252520%252520special%252520%25253D%252520false%25250A%252520%252520upper%252520%252520%252520%25253D%252520false%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D2x%26wm%3Dfalse%26code%3Dresource%25252520%25252522random_string%25252522%25252520%25252522random_sixteen%25252522%25252520%2525257B%2525250A%25252520%25252520length%25252520%25252520%2525253D%2525252016%2525250A%25252520%25252520special%25252520%2525253D%25252520false%2525250A%25252520%25252520upper%25252520%25252520%25252520%2525253D%25252520false%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0e7ae781cb46a477ea0d9ab72be60a6/href">https://medium.com/media/e0e7ae781cb46a477ea0d9ab72be60a6/href</a></iframe><p>Consider the resource above. We are trying to create a string with 16 characters. It does not have any special or upper case characters. If we had to make any change to any of the values here, it would require us going into the code and making a change, modifying our commit history too.</p><p>In any programming language, variables play a central role while building software. Why should Terraform be left out?! 🙂</p><p>Let us replace the above snippet with some variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*kk3RM61iL1NW7yPJtUj2qw.png" /><figcaption>Resource replaced with variables</figcaption></figure><p>Now the next time you run a terraform plan , it will prompt you to input the values of the 3 variables random_string_length , include_special , and include_upper. You can alternatively pass a variable values file, affectionately known as a tfvars file. Terraform will look for a file in the current folder named as terraform.tfvars for values of the variables. You can pass other files using the --var-file=&lt;file_name&gt;.tfvars argument while executing terraform plan/apply.</p><p>Don’t worry if you have not passed in the values of all the variables. For any variable whose value cannot be found either in a tfvar file or as a default value in variable definition, Terraform will prompt you to enter a value at <strong>runtime</strong> while executing a plan or apply.</p><p>Let us look at the other types of variables in Terraform</p><h3><strong>Output Variables</strong></h3><p>Relating back to programming languages, a function or a method generally has a return type. It can be <strong>void</strong>, <strong>int</strong>, <strong>string</strong> or an <strong>object</strong>. Terraform allows us to do that too. Almost every resource has some outputs. They can be found under the <strong>“attributes”</strong> section of the said resource’s documentation. Any of these attributes can be used as output variable.</p><p>Output variables allow us to view and export the results to other resources or programs. On running terraform apply, it will print the output variables values on the console. This is especially useful when you would require the ARN (Amazon Resource Name) or the IDs of some specific resources.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%3Fbg%3Drgba%2528171%252C%2B184%252C%2B195%252C%2B1%2529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%2525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Doutput%252520%252522bucket_name%252522%252520%25257B%25250A%252520%252520value%252520%25253D%252520aws_s3_bucket.state_bucket.id%25250A%25257D%25250A%25250Aoutput%252520%252522bucket_arn%252522%252520%25257B%25250A%252520%252520value%252520%25253D%252520aws_s3_bucket.state_bucket.arn%25250A%25257D&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2F%3Fbg%3Drgba%252528171%25252C%2B184%25252C%2B195%25252C%2B1%252529%26t%3Dmonokai%26wt%3Dnone%26l%3Dauto%26ds%3Dtrue%26dsyoff%3D20px%26dsblur%3D68px%26wc%3Dtrue%26wa%3Dtrue%26pv%3D56px%26ph%3D56px%26ln%3Dfalse%26fl%3D1%26fm%3DHack%26fs%3D14px%26lh%3D133%252525%26si%3Dfalse%26es%3D1x%26wm%3Dfalse%26code%3Doutput%25252520%25252522bucket_name%25252522%25252520%2525257B%2525250A%25252520%25252520value%25252520%2525253D%25252520aws_s3_bucket.state_bucket.id%2525250A%2525257D%2525250A%2525250Aoutput%25252520%25252522bucket_arn%25252522%25252520%2525257B%2525250A%25252520%25252520value%25252520%2525253D%25252520aws_s3_bucket.state_bucket.arn%2525250A%2525257D&amp;image=https%3A%2F%2Fcarbon.now.sh%2Fstatic%2Fbrand%2Fbanner.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d052c8dfa35a0142499068e188a70194/href">https://medium.com/media/d052c8dfa35a0142499068e188a70194/href</a></iframe><p>The value can be referenced using resource_type.resource_name.attribute_name as seen in the example above. Here we output the ID and the ARN of the S3 Buckets that we had created earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ugD0jy2i1szQP9ma8fHmEw.png" /><figcaption>Sample output in console</figcaption></figure><p>With output variables out of the way, let’s move on to the local variables</p><h3>Local Variables</h3><p>Relating back to programming languages, we have the concept of local variables. Local variables are variables whose <strong>scope is limited to the current function only</strong>. In Terraform, local variables’ scope is limited to the current context and all the resources defined in current context. They are generally used to build out values. Consider the use case where you would like to define the general tags that all resources in the current context should have. It would be cumbersome to write the value at every resource. Instead one could define a local variable block which builds out the tags depending on the environment, project, resource etc. They can be later referenced using HCL syntax with ease throughout the resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*HyYP598RhQkc5-Je9USRug.png" /></figure><p>Notice how we can use other resources’ outputs inside the local block.</p><h3>Up next</h3><p>In the next part of this series (i.e. Part 2), we will explore <strong>Data Sources</strong> in Terraform. Watch this space… 🙂</p><h3>Video and code</h3><p>Each blog in this series is accompanied with a corresponding YouTube video and code on GitHub. Here is the <a href="https://github.com/Arkoprabho/TerraformTutorial"><strong>GitHub code</strong></a> and you can find the <strong>video</strong> below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDy_pqerWBSM&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDy_pqerWBSM&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FDy_pqerWBSM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/86dccc723fad02cdb08f939a9df58dc2/href">https://medium.com/media/86dccc723fad02cdb08f939a9df58dc2/href</a></iframe><p>Follow me on <a href="https://www.linkedin.com/in/arkoprabho/">LinkedIn</a> and <a href="https://github.com/Arkoprabho">Github</a>.</p><p>Follow Technogise on <a href="https://www.linkedin.com/company/technogise/">LinkedIn</a>, <a href="https://twitter.com/technogise">Twitter</a>, <a href="https://youtube.com/c/technogiseprivatelimited">YouTube</a>, <a href="https://www.meetup.com/technowise">Meetup</a> for more such insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f405c2db47b3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/technogise/terraform-zero-to-hero-part-1-variables-f405c2db47b3">Terraform Zero to Hero: Part 1 Variables</a> was originally published in <a href="https://medium.com/technogise">Technogise</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform Zero to Hero: Part 0]]></title>
            <link>https://medium.com/technogise/terraform-zero-to-hero-part-0-e5bf0429f7d6?source=rss-8d6fa3d84ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5bf0429f7d6</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Arko Chakraborti]]></dc:creator>
            <pubDate>Mon, 31 May 2021 06:54:26 GMT</pubDate>
            <atom:updated>2021-06-15T04:12:47.952Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/946/0*kLH_gytLfBJODI8W" /></figure><p>You have an application that needs to be publicly accessible. What do you do? Install ngrok, start your application, route it to your local server. Easy right?!</p><p>But then you decide to shutdown your system, or maybe there’s a power cut, or maybe the load simply exceeds the abilities of your system. What do you do?<br>Well, you go to one of the Cloud platforms (...AWS / Azure / GCP / any others, which are all the rage…) and create a lucrative free account. You experiment with basic VM and quickly realise that this can potentially solve your issues. Great!<br>You spin it up, set up your code and expose it to the internet via the public IP.</p><p>But soon you realise that a dedicated database would be a better idea, and you find out that the cloud provider has a solution for that too.<br>You create a managed database instance, secure it with a user id and password and connect it to your VM.</p><p>But wait a second! Your database is publicly exposed. Do you really want that?<br>Wouldn’t it be amazing if you could keep your VM and DB instances in a local network and expose only your VM? That reduces your contact point with the internet. And we all know how dangerous the internet is.<br>Cool! Off to creating a virtual private cloud (VPC) then.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/0*_4mRM5DQXT4GwRZb" /></figure><p>Now, what if I told you that in the time you spent reading the above scenario, you can spin up the entire set up defined with simply one command from your terminal?<br>What if I told you that all the infrastructure you can think of on the cloud can be created, destroyed, modified with a single command? Sounds like a dream right? Well, what if I told you that it’s a solved problem… 🙂</p><h3>Introducing Terraform</h3><p>Terraform is an open-source infrastructure as code (IaC) tool that provides a consistent CLI workflow to manage hundreds of cloud services.</p><p>Terraform follows a declarative approach to IaC. One simply defines <strong>what</strong> they want; not how they want it. Terraform processes it and smartly generates a plan of what all needs to be done.</p><p>In this “n” part series we will explore what Terraform is, and understand how to work with it. Each part will be accompanied by code. Each part has a <a href="https://github.com/Arkoprabho/TerraformTutorial"><strong>corresponding tag on Github</strong></a>.</p><h3>Terminologies</h3><p>Before we dive into code, let’s understand a few terminologies around Terraform.</p><ol><li>Providers</li><li>Resources</li><li>Data Sources</li><li>Variables (input, output, local)</li><li>State file</li><li>Meta Arguments</li><li>Functions</li></ol><p>There are a lot more keywords around Terraform, but these should cover about 90% of our use cases. Let’s briefly go through them</p><h4>Providers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*OGQfc92e_ldD1JvvqR9tAA.png" /><figcaption>AWS Provider</figcaption></figure><p>Terraform simply provides us with a platform to create infrastructure. It does not automatically enable us to do that.<br>In order to create infrastructure on a specific cloud platform, we need a tool that can hook on to Terraform. These tools are called providers. They act like plugins to Terraform and enable it to communicate with the cloud platform. The example in the image instructs Terraform 3 things:</p><ol><li>The cloud provider to target (AWS)</li><li>The default region, and</li><li>The local AWS CLI profile to use to communicate with the cloud infrastructure.</li></ol><p>This CLI profile needs to have enough <strong>permissions</strong> for Terraform to work as expected. Terraform will use this profile to spin up the resources.</p><p>Thus, if you do not have permission to modify EC2 instances on your profile, you will not be able to do the same via Terraform either. The provider dictates the types of resources and data sources you have access to. More on this later…</p><h4>Resources</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*Zh19UophhFoq0uONCN5u0Q.png" /><figcaption>Resources for S3 and DynamoDB table on AWS</figcaption></figure><p>Resources are the most important element in the Terraform language. Each resource block describes one or more infrastructure objects, such as virtual networks, compute instances, or higher-level components such as DNS records.</p><p>A resource block declares a resource of a given type aws_s3_bucket with a given local name sample_bucket. The name is used to refer to this resource from elsewhere in the same Terraform module, but has no significance outside that module’s scope.<br>Imagine an analogy to programming, where aws_s3_bucket would be the data type and sample_bucket would be the name of the variable. A lot like int sample_bucket.<br>To have a more concrete analogy, each resource is like a class. We use the Terraform syntax to set specific arguments of the class, and once done, we get a few attributes in return.</p><h4>Data Sources</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*ZpN36uGYyx_SvVzZJM75bw.png" /></figure><p>Data sources allow data to be fetched or computed for use elsewhere in Terraform configuration.<br>Use of data sources allows a Terraform configuration to make use of information defined <strong>outside</strong> of Terraform, or defined by another <strong>separate</strong> Terraform configuration.<br>We can use a similar analogy to programming languages here as we did for resources. aws_iam_policy is the data type; devops is the name of the variable.<br>Data sources differ from resources in one key way. They DO NOT create any infrastructure. They are strictly used to fetch information. In the image attached, this block in itself will NOT create an IAM Policy, but will simply generate the skeleton. We will need to create a dedicated resource where we pass this data source as input.</p><h4>Variables</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*cCNSRprVal72Bsj5sL0pfQ.png" /></figure><p>We have 3 types of variables:</p><ol><li>Input variables: Sends values to Terraform.</li><li>Output variables: Retrieves values from Terraform.</li><li>Local variables: Assigns names to an expression.</li></ol><h4>State File</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*0oinn5ChyTU83S1U0WMBjA.png" /></figure><p>State files are what Terraform uses to understand the cloud infrastructure.<br>State files are central to Terraform’s working. This state is used by Terraform to map real world resources to your configuration, keep track of metadata, and to improve performance for large infrastructures. Whenever we make any changes to our Terraform code, it will be compared against the state file and create a diff of what needs to be done.</p><h4>Meta Arguments</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*8uvNv0-uXA82sFkr5DeJOw.png" /></figure><p>Each resource has its own set of arguments, as defined by the provider. Terraform plugs in some of its own arguments too. It lets us control the behaviour of the resource creation to some extent. Conditions like dependency management, multiple resource instances of the same type etc., can be controlled using the meta arguments. The Terraform language defines several meta-arguments, which can be used with any resource type to change the behaviour of resources. E.g. depends_on, count, for_each, provider, lifecycle, provisioner, connection</p><h4>Functions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGExExiMDthzjjVQEQPdAw.png" /></figure><p>Most programming languages have some functions that are associated with each object, or are available in the standard library itself. Terraform has them too. Functions are further broken down into several types. Numeric, string, collection, encoding, type conversion etc. In the example above, we can see 2 functions being used, lookup and templatefile.<br>The lookup function searches a map by its key. The templatefile function reads the file at the given path and renders its content as a template using a supplied set of template variables.</p><p><strong>We will dive into depth in each one of these parts in the upcoming parts of the series</strong>. Watch this space for updates.<br>Follow me on <a href="https://www.linkedin.com/in/arkoprabho/">LinkedIn</a> and <a href="https://github.com/Arkoprabho">Github</a>. Follow Technogise on <a href="https://www.linkedin.com/company/technogise/">LinkedIn</a>, <a href="https://twitter.com/technogise">Twitter</a>, <a href="https://youtube.com/c/technogiseprivatelimited">YouTube</a>, <a href="https://www.meetup.com/technowise">Meetup</a> for more such insights.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5bf0429f7d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/technogise/terraform-zero-to-hero-part-0-e5bf0429f7d6">Terraform Zero to Hero: Part 0</a> was originally published in <a href="https://medium.com/technogise">Technogise</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>