{"id":27328,"date":"2022-02-22T12:15:38","date_gmt":"2022-02-22T12:15:38","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=27328"},"modified":"2022-12-23T06:48:52","modified_gmt":"2022-12-23T06:48:52","slug":"what-is-the-use-of-terraform-in-devops","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/what-is-the-use-of-terraform-in-devops\/","title":{"rendered":"What is the use of Terraform in DevOps?"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><strong>What is<\/strong> <strong>Terraform in DevOps and Its history &amp; origin?<\/strong><\/p>\n\n\n\n<p>Hi friend, today in this blog I&#8217;ll explain about Terraform in DevOps and Its history &amp; origin as well, lets know about Terraform, It is an open-source tool and it is a multi-cloud, infrastructure-as-code solution, developed by Hashicorp, that makes use of the declarative Hashicorp Configuration Language. It helps you manage existing, popular service providers like GCP, AWS, as well as custom in-house solutions. It manages external resources (such as public cloud infrastructure, private cloud infrastructure, network appliances, software as a service, and platform as a service) with &#8220;providers&#8221;.<\/p>\n\n\n\n<p><strong>These are the some important points about Terraform<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Original author(s) &#8211; Mitchell Hashimoto et al.<\/li><li>Developer(s) &#8211; HashiCorp<\/li><li>Initial release 28 July 2014<\/li><li>It also supports a Terraform Module Registry, launched in 2017.<\/li><li>In 2019, Terraform introduced the paid version called Terraform Enterprise for larger organizations.<\/li><\/ul>\n\n\n\n<p><strong>How does Terraform work?<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"368\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/how-does-terraform-work.png\" alt=\"\" class=\"wp-image-27330\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/how-does-terraform-work.png 886w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/how-does-terraform-work-300x125.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/how-does-terraform-work-768x319.png 768w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/figure>\n\n\n\n<p><strong>The core Terraform workflow consists of three stages:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/terraform-workflow.png\" alt=\"\" class=\"wp-image-27333\" width=\"842\" height=\"730\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/terraform-workflow.png 592w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/02\/terraform-workflow-300x260.png 300w\" sizes=\"auto, (max-width: 842px) 100vw, 842px\" \/><\/figure>\n\n\n\n<p><strong>Importance of Terraform:-<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The Terraform state file keeps track of all changes in an environment.<\/li><li>It offers a great way to package and reuse common code in the form of modules.<\/li><li>Its modules are comparable to functions or methods in scripting or programming languages.<\/li><li>State files can also serve as a data source that can be imported by other Terraform projects.<\/li><\/ul>\n\n\n\n<p><strong>These version controls supported by Terraform<\/strong><\/p>\n\n\n\n<p>The supported version controls are:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Azure DevOps Services<\/li><li>Azure DevOps Server<\/li><li>Bitbucket Server<\/li><li>Bitbucket Cloud<\/li><li>Gitlab EE and CE<\/li><li>Gitlab.com<\/li><li>GitHub Enterprise<\/li><li>GitHub.com (OAuth)<\/li><li>GitHub.com<\/li><\/ul>\n\n\n\n<p><strong>These are the features of Terraform:-<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Terraform can manage parallel environments.<\/li><li>It manages external services providers very easily.<\/li><li>It can manage multiple clouds to increase fault tolerance.<\/li><li>It follows a Declarative approach for faster developments.<\/li><li>It helps to display the resulting model in a graphical and easy-to-understand form.<\/li><li>Its modular code plays a major role in achieving consistency, reusability, and collaboration.<\/li><\/ul>\n\n\n\n<p><strong>What are the most useful Terraform commands?<\/strong><\/p>\n\n\n\n<p>These are some of the most useful Terraform commands are:<\/p>\n\n\n\n<p>terraform init &#8211; initializes the current directory<br>terraform refresh &#8211; refreshes the state file<br>terraform output &#8211; views Terraform outputs<br>terraform apply &#8211; applies the Terraform code and builds stuff<br>terraform destroy &#8211; destroys what has been built by Terraform<br>terraform graph &#8211; creates a DOT-formatted graph<br>terraform plan &#8211; a dry run to see what Terraform will do<\/p>\n\n\n\n<p><strong>Explain the uses of Terraform CLI and list some basic CLI commands?<\/strong><\/p>\n\n\n\n<p>The Terraform Command-Line Interface (CLI) is used to manage infrastructure and interact with Terraform state, configuration files, providers, etc.<\/p>\n\n\n\n<p><strong>Here are some basic CLI commands:<\/strong><\/p>\n\n\n\n<p>terraform init &#8211; prepares your working directory for other commands<br>terraform destroy &#8211; destroys the previously-created infrastructure<br>terraform validate &#8211; check whether the configuration is valid<br>terraform apply &#8211; creates or updates the infrastructure<br>terraform plan &#8211; shows changes needed by the current configuration<\/p>\n\n\n\n<p><strong>Prerequisites for Terraform:-<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>At least 10GB of disk space on the root volume.<\/li><li>At least 40GB of disk space for the Docker data directory (defaults to \/var\/lib\/docker )<\/li><li>At least 8GB of system memory.<\/li><\/ul>\n\n\n\n<p>If you are planning to prepare for the <a href=\"https:\/\/www.devopsschool.com\/certification\/hashicorp-certified-terraform-associate.html\">Hashicorp Terraform certification<\/a> then I would suggest you DevOpsSchool Institutes name where you can get quality training by experts. If you are planning to learn terraform then watch this tutorial and get all info.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Terraform Fundamental Tutorial By Guru in 2020 Part-1\" width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/P_nZPuZRwmI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Terraform Fundamental Tutorials by Harish in 2020\" width=\"720\" height=\"540\" src=\"https:\/\/www.youtube.com\/embed\/0-z1G0BFZSU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Terraform in DevOps and Its history &amp; origin? Hi friend, today in this blog I&#8217;ll explain about Terraform in DevOps and Its history &amp; origin as well, lets know about Terraform, It is an open-source tool and it is a multi-cloud, infrastructure-as-code solution, developed by Hashicorp, that makes use of the declarative Hashicorp&#8230;<\/p>\n","protected":false},"author":1,"featured_media":27349,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[2],"tags":[7341,95,296,7343,5130,7342,7344],"class_list":["post-27328","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorised","tag-cli-commands","tag-devops","tag-features","tag-hashicorp","tag-terraform","tag-terraform-cli","tag-terraform-workflow"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/27328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=27328"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/27328\/revisions"}],"predecessor-version":[{"id":27352,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/27328\/revisions\/27352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/27349"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=27328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=27328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=27328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}