<?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>G Kameswar Rao &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/author/g-kameswar-rao/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bestdevops.com</link>
	<description>Lets Learn, Do it &#38; Share! Thats a Best DevOps!!!</description>
	<lastBuildDate>Tue, 05 Jul 2022 01:39:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>Terraform 04-July day-01 By G Kameswar Rao</title>
		<link>https://www.bestdevops.com/terraform-04-july-day-01-by-g-kameswar-rao/</link>
					<comments>https://www.bestdevops.com/terraform-04-july-day-01-by-g-kameswar-rao/#respond</comments>
		
		<dc:creator><![CDATA[G Kameswar Rao]]></dc:creator>
		<pubDate>Tue, 05 Jul 2022 01:38:02 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<guid isPermaLink="false">https://www.bestdevops.com/?p=24747</guid>

					<description><![CDATA[Assignment &#8211; 1 List of Components of Terraform and explain each components with 1 image 1.Terraform Code (HCL) Terraform code [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Assignment &#8211; 1</h2>



<p class="wp-block-paragraph">List of Components of Terraform and explain each components with 1 image</p>



<p class="wp-block-paragraph">1.<strong>Terraform Code (HCL)</strong></p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="857" src="https://www.bestdevops.com/wp-content/uploads/2022/07/tf1-code-1024x857.jpg" alt="" class="wp-image-24902" srcset="https://www.bestdevops.com/wp-content/uploads/2022/07/tf1-code-1024x857.jpg 1024w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf1-code-300x251.jpg 300w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf1-code-768x643.jpg 768w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf1-code.jpg 1201w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Terraform code is expressed as a declarative code which contains declaration of resources, providers and necessary code for infrastructure deployment and management acting as single input source file for terraform executable. </p>



<p class="wp-block-paragraph"><strong>2. Terraform Executable</strong></p>



<p class="wp-block-paragraph">Terraform Executable provides command line interface tool that will allow developer to run / perform all the terraform commands on terraform project/code.</p>



<p class="wp-block-paragraph">Following are mostly used Terraform commands:</p>



<ol class="wp-block-list"><li><strong>terraform init</strong> : This command allows to add/download necessary providers in the terraform project based on the declaration in terraform code. It is necessary to execute &#8220;INIT&#8221; command in the beginning of any project.</li><li><strong>terraform validate: </strong> Validate command will check the necessary syntax and  blocks are in place for successful execution by performing local scan.</li><li><strong>terraform plan:</strong> To ensure the configuration file will work as expected. And also allow developer to preview the necessary changes going to take place.</li><li><strong>terraform apply:</strong> It will execute the actions proposed in terraform plan.</li><li><strong>terraform destroy:</strong> It will destroy all the remote resources declared in terraform configuration file.</li></ol>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="643" src="https://www.bestdevops.com/wp-content/uploads/2022/07/tf-02-1024x643.jpg" alt="" class="wp-image-24909" srcset="https://www.bestdevops.com/wp-content/uploads/2022/07/tf-02-1024x643.jpg 1024w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf-02-300x188.jpg 300w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf-02-768x482.jpg 768w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf-02.jpg 1269w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"><strong>3. Terraform Provider</strong></p>



<p class="wp-block-paragraph">Providers allows to interact with different platforms. It acts as a mediator to provide connectivity from terraform code to the platform(AzureRM) to access its API. The azurerm provider helps terraform code on how to interact with azurerm API.</p>



<p class="wp-block-paragraph">Below is the screenshot showing declaration of Provider for &#8220;azurerm&#8221; in terraform code.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="249" src="https://www.bestdevops.com/wp-content/uploads/2022/07/tf-03-1024x249.jpg" alt="" class="wp-image-24913" srcset="https://www.bestdevops.com/wp-content/uploads/2022/07/tf-03-1024x249.jpg 1024w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf-03-300x73.jpg 300w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf-03-768x187.jpg 768w, https://www.bestdevops.com/wp-content/uploads/2022/07/tf-03.jpg 1353w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"><strong>4.Terraform State </strong>:</p>



<p class="wp-block-paragraph">It is the terraform state file generated to capture the current state of the remote resources as a response to the create, update and destroy commands. This will allow terraform to know the current state of the resources define in the terraform code compared against the one in remote service. It contains all the necessary details like IP address, Secrets, and Keys from remote resources so it need to be properly guarded.</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading">Assignment – 2</h2>



<p class="wp-block-paragraph">Write a terraform file which must create 1 azure resources group + 1 aws instance and 1 github repo. All the code must be into 1 file including providers.</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">terraform {
    required_providers {
        azurerm = {
            source = <span class="hljs-string">"hashicorp/azurerm"</span>
            version = <span class="hljs-string">"3.12.0"</span>
        }
        aws = {
            source = <span class="hljs-string">"hashicorp/aws"</span>
            version = <span class="hljs-string">"4.21.0"</span>
        }
        github = {
            source = <span class="hljs-string">"integrations/github"</span>
            version = <span class="hljs-string">"4.26.1"</span>
        }
    }    
}

provider <span class="hljs-string">"azurerm"</span> {

    features{}

    subscription_id = <span class="hljs-string">"test-00000000-0000-0000-0000-000000000000"</span>
    client_id       = <span class="hljs-string">"test-00000000-0000-0000-0000-000000000000"</span>
    client_secret   = <span class="hljs-string">"test-afdfafsefgwrgwrwye"</span>
    tenant_id       = <span class="hljs-string">"test-00000000-0000-0000-0000-000000000000"</span>

}

provider <span class="hljs-string">"aws"</span> {
    access_key = <span class="hljs-string">"test-AKIAQ6GAIA5XIHHM2GJM"</span>
    secret_key = <span class="hljs-string">"test-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"</span>
    region = <span class="hljs-string">"eu-west-3"</span>
}

provider <span class="hljs-string">"github"</span> {
  token = <span class="hljs-string">"testghp_Ii7t3DexYVxBGwqHOlgnLXOS2BTZ1s"</span>
}

resource <span class="hljs-string">"azurerm_resource_group"</span> <span class="hljs-string">"asgnmt2_rg"</span> {
    name = <span class="hljs-string">"assignment02_Rg"</span>
    location = <span class="hljs-string">"East US"</span>
}

resource <span class="hljs-string">"aws_instance"</span> <span class="hljs-string">"web"</span> {
  ami           = <span class="hljs-string">"ami-a1b2c3d4"</span>
  instance_type = <span class="hljs-string">"t2.micro"</span>
}

resource <span class="hljs-string">"github_repository"</span> <span class="hljs-string">"repo"</span> {
    name = <span class="hljs-string">"assignment02_repo"</span>
    description = <span class="hljs-string">"This repository created as a result by executing terraform script using github Provider"</span>
    visibility = <span class="hljs-string">"public"</span>
}

</code></span></pre>]]></content:encoded>
					
					<wfw:commentRss>https://www.bestdevops.com/terraform-04-july-day-01-by-g-kameswar-rao/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
