{"id":22130,"date":"2024-04-13T00:00:15","date_gmt":"2024-04-12T21:00:15","guid":{"rendered":"https:\/\/kifarunix.com\/?p=22130"},"modified":"2024-04-13T23:34:04","modified_gmt":"2024-04-13T20:34:04","slug":"install-terraform-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-terraform-on-ubuntu-24-04\/","title":{"rendered":"Install Terraform on Ubuntu 24.04"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1051\" height=\"588\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/04\/terraform.png\" alt=\"Install Terraform on Ubuntu 24.04\" class=\"wp-image-22139\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/04\/terraform.png?v=1712955520 1051w, https:\/\/kifarunix.com\/wp-content\/uploads\/2024\/04\/terraform-768x430.png?v=1712955520 768w\" sizes=\"(max-width: 1051px) 100vw, 1051px\" \/><\/figure>\n\n\n\n<p>How can I install Terraform on Ubuntu 24.04 for automated deployments and infrastructure provisioning? This guide will provide step-by-step tutorial on installing Terraform on Ubuntu 24.04. <a href=\"https:\/\/developer.hashicorp.com\/terraform\/intro\" target=\"_blank\" rel=\"noreferrer noopener\">Terraform<\/a> is an Infrastructure as Code tool that enables you to provision various cloud or on-prem resources such your infrastructure servers, serverless cloud functions, Kubernetes clusters, networking tasks e.t.c in a versionable, reusable and shareable manner.<\/p>\n\n\n\n<p>To learn the basics of Terraform, check the guide below;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/introduction-to-terraform-understanding-basic-architecture\/\" target=\"_blank\" rel=\"noreferrer noopener\">Introduction to Terraform: Understanding Basic Architecture<\/a><\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#installing-terraform-on-ubuntu-24-04\">Installing Terraform on Ubuntu 24.04<\/a><ul><li><a href=\"#installing-terraform-from-apt-repository\">Installing Terraform from APT Repository<\/a><ul><li><a href=\"#install-hashi-corp-apt-repository\">Install HashiCorp APT Repository<\/a><\/li><li><a href=\"#install-terraform-from-hashi-corp-repository\">Install Terraform from HashiCorp Repository<\/a><\/li><\/ul><\/li><li><a href=\"#installing-terraform-using-binary-file\">Installing Terraform using Binary file<\/a><\/li><li><a href=\"#using-terraform-on-cli\">Using Terraform on CLI<\/a><\/li><li><a href=\"#getting-started-with-terraform\">Getting Started with Terraform<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-terraform-on-ubuntu-24-04\">Installing Terraform on Ubuntu 24.04<\/h2>\n\n\n\n<p>So, if you want to see Terraform in action on your local environment, how can you install it? Follow through this guide to learn how to install Terraform.<\/p>\n\n\n\n<p>There are two ways in which you can install Terraform:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install via APT Repository<\/li>\n\n\n\n<li>Install using Binary file<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-terraform-from-apt-repository\">Installing Terraform from APT Repository<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-hashi-corp-apt-repository\">Install HashiCorp APT Repository<\/h4>\n\n\n\n<p>Ubuntu default repositories do not provide Terraform package. As a result, you need to install the HashiCorp APT repository that let&#8217;s you install Terraform on your Ubuntu Linux system.<\/p>\n\n\n\n<p>Run the commands below to install HashiCorp APT repository on Ubuntu 24.04.<\/p>\n\n\n\n<p>Install the required packages to setup the repository.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y gnupg software-properties-common<\/code><\/pre>\n\n\n\n<p>Install the HashiCorp&nbsp;APT repository GPG key.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -O- https:\/\/apt.releases.hashicorp.com\/gpg | sudo gpg --dearmor -o \/etc\/apt\/trusted.gpg.d\/hashicorp-archive-keyring.gpg<\/code><\/pre>\n\n\n\n<p>Install HashiCorp repository;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb https:\/\/apt.releases.hashicorp.com $(lsb_release -cs) main\" | sudo tee \/etc\/apt\/sources.list.d\/hashicorp.list<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"install-terraform-from-hashi-corp-repository\">Install Terraform from HashiCorp Repository<\/h4>\n\n\n\n<p>Once the repository is installed, proceed to install Terraform.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install terraform<\/code><\/pre>\n\n\n\n<p>And Terraform should now be installed on your Ubuntu Linux system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-terraform-using-binary-file\">Installing Terraform using Binary file<\/h3>\n\n\n\n<p>If you do not want to install HashiCorp APT repositories, you can install Terraform using binary. Navigate to the <a href=\"https:\/\/developer.hashicorp.com\/terraform\/install#linux\" target=\"_blank\" rel=\"noopener\">Linux binary downloads page<\/a> and grab a binary of your respective system architecture, e.g amd64;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/releases.hashicorp.com\/terraform\/1.8.0\/terraform_1.8.0_linux_amd64.zip<\/code><\/pre>\n\n\n\n<p>Once you have downloaded the binary, extract it to the system binaries directory. We use <strong>\/usr\/local\/bin<\/strong> in this guide.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo unzip terraform_1.8.0_linux_amd64.zip -d \/usr\/local\/bin\/<\/code><\/pre>\n\n\n\n<p>Make the binary executable;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod +x \/usr\/local\/bin\/terraform<\/code><\/pre>\n\n\n\n<p>And that is it!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"using-terraform-on-cli\">Using Terraform on CLI<\/h3>\n\n\n\n<p>As a verification that Terraform has been installed and functioning as expected, you can try to run a few Terraform commands;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>terraform -version<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Terraform v1.8.0\non linux_amd64\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>terraform -help<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Usage: terraform [global options] <subcommand> [args]\n\nThe available commands for execution are listed below.\nThe primary workflow commands are given first, followed by\nless common or more advanced commands.\n\nMain commands:\n  init          Prepare your working directory for other commands\n  validate      Check whether the configuration is valid\n  plan          Show changes required by the current configuration\n  apply         Create or update infrastructure\n  destroy       Destroy previously-created infrastructure\n\nAll other commands:\n  console       Try Terraform expressions at an interactive command prompt\n  fmt           Reformat your configuration in the standard style\n  force-unlock  Release a stuck lock on the current workspace\n  get           Install or upgrade remote Terraform modules\n  graph         Generate a Graphviz graph of the steps in an operation\n  import        Associate existing infrastructure with a Terraform resource\n  login         Obtain and save credentials for a remote host\n  logout        Remove locally-stored credentials for a remote host\n  metadata      Metadata related commands\n  output        Show output values from your root module\n  providers     Show the providers required for this configuration\n  refresh       Update the state to match remote systems\n  show          Show the current state or a saved plan\n  state         Advanced state management\n  taint         Mark a resource instance as not fully functional\n  test          Execute integration tests for Terraform modules\n  untaint       Remove the 'tainted' state from a resource instance\n  version       Show the current Terraform version\n  workspace     Workspace management\n\nGlobal options (use these before the subcommand, if any):\n  -chdir=DIR    Switch to a different working directory before executing the\n                given subcommand.\n  -help         Show this help output, or the help for a specified subcommand.\n  -version      An alias for the \"version\" subcommand.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"getting-started-with-terraform\">Getting Started with Terraform<\/h3>\n\n\n\n<p>You can now get started with Terraform to provision your infrastructure.<\/p>\n\n\n\n<p>Read more on <a href=\"https:\/\/developer.hashicorp.com\/terraform\/tutorials\" target=\"_blank\" rel=\"noreferrer noopener\">Terraform Tutorials page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can I install Terraform on Ubuntu 24.04 for automated deployments and infrastructure provisioning? This guide will provide step-by-step tutorial on installing Terraform on Ubuntu<\/p>\n","protected":false},"author":10,"featured_media":22139,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,1722],"tags":[7443,7445,7396,7444],"class_list":["post-22130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-automation-2","tag-install-terraform-ubuntu","tag-terraform","tag-ubuntu-24-04","tag-ubuntu-24-04-terraform","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22130"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=22130"}],"version-history":[{"count":13,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22130\/revisions"}],"predecessor-version":[{"id":22158,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22130\/revisions\/22158"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/22139"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=22130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=22130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=22130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}