{"id":78348,"date":"2021-04-13T23:32:04","date_gmt":"2021-04-13T23:32:04","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=78348"},"modified":"2026-09-08T10:29:18","modified_gmt":"2026-09-08T04:59:18","slug":"terraform-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/","title":{"rendered":"Terraform Cheat Sheet"},"content":{"rendered":"<p><i><span style=\"font-weight: 400;\">Aspiring to become a Terraform expert? Check out this exclusive <strong>Terraform cheat sheet<\/strong> that will help you become a Terraform pro!<\/span><\/i><\/p>\n<p><span style=\"font-weight: 400;\">Terraform is a productive tool that came out in 2014. It is quite essential for describing a complete infrastructure of an application or software through integrated measures. Certain commands and code are commonly used within the tool for specific functions.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Beginners might experience a tough time mastering the commands and sub-commands of Terraform. This IaC tool is highly intuitive, and to get the best out of it, you will need to keep in mind the basic commands that are to be called within it. For that, cheat sheets are the optimal remedy to work with Terraform while you are progressing in memorising the commands.<\/span><\/p>\n<blockquote><p><a href=\"https:\/\/www.whizlabs.com\/blog\/what-is-terraform-terraform-tutorial\/\">What is Terraform? Terraform Tutorial Learn in 30 Minutes!<\/a><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Hence, this <\/span><b>Terraform cheat sheet<\/b><span style=\"font-weight: 400;\"> is destined to help serve that purpose and make you aware of those commonly used Terraform codes or commands.<\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ea7e02;color:#ea7e02\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ea7e02;color:#ea7e02\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#Terraform_CLI_Commands_%E2%80%93_Terraform_Cheat_Sheet\" >Terraform CLI Commands &#8211; Terraform Cheat Sheet<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#1_Terraform_CLI_Help\" >1. Terraform CLI Help<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#2_Show_Version_Command\" >2. Show Version Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#3_Initialise_Infrastructure_Commands\" >3. Initialise Infrastructure Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#4_Get_Commands\" >4. Get Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#5_Provision_Infrastructure_Commands\" >5. Provision Infrastructure Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#6_Terraform_Workspace_Commands\" >6. Terraform Workspace Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#7_Format_and_Validate_Terraform_Command_or_Code\" >7. Format and Validate Terraform Command or Code<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#8_Inspect_Infrastructure_Commands\" >8. Inspect Infrastructure Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#9_Terraform_Import_Commands\" >9. Terraform Import Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#10_Terraform_State_Manipulation_Commands\" >10. Terraform State Manipulation Commands<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#11_Terraform_Miscellaneous_Commands\" >11. Terraform Miscellaneous Commands<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.whizlabs.com\/blog\/terraform-cheat-sheet\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Terraform_CLI_Commands_%E2%80%93_Terraform_Cheat_Sheet\"><\/span><b>Terraform CLI Commands &#8211; Terraform Cheat Sheet<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The Command-Line Interface consists of commonly used, advanced, and less common commands. All of these commands and subcommands are used to call different functions within the tool. Let\u2019s cover all possible commands within Terraform under this\u00a0<\/span><b>Terraform cheat sheet<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-78355\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1.png\" alt=\"most commonly used Terraform commands\" width=\"1280\" height=\"720\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1.png 1280w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1-300x169.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1-1024x576.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1-768x432.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1-747x420.png 747w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1-640x360.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/codes-1-681x383.png 681w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-78354\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1.png\" alt=\"most commonly used Terraform commands\" width=\"1280\" height=\"720\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1.png 1280w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1-300x169.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1-1024x576.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1-768x432.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1-747x420.png 747w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1-640x360.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/main.tf-configure-the-Heroku-provider-provider-_heroku_-email-_var.heroku_account_email_-api_key-_var.heroku_api_key_-You-can-find-Heroku-API-Key-at-https___dashboard.heroku.com_account-1-681x383.png 681w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">This image consists of some of the most commonly used Terraform commands that you must adapt and utilise in the right manner to access select functions. Apart from these, there are many other advanced commands and subcommands that you will explore further in this <\/span><b>Terraform cheat sheet<\/b><span style=\"font-weight: 400;\">. <\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Terraform_CLI_Help\"><\/span><b>1. Terraform CLI Help<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">In case you need help with any of the commands within the tool, Terraform has a built-in help function that can be called by using specific help commands for the same.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The command is\u00a0<\/span><b>terraform &lt;commandname&gt; &#8211; help<\/b><\/p>\n<p><span style=\"font-weight: 400;\">For instance, if you are willing to get help on the subcommand \u2018state\u2019, then you will have to run <\/span><b>terraform state help. <\/b><span style=\"font-weight: 400;\">You can do it with any of the subcommands embedded within Terraform. The commands and subcommands that are involved within the functionality of this tool are listed further in this\u00a0<\/span><b>Terraform cheat sheet<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Show_Version_Command\"><\/span><b>2. Show Version Command<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">The show version command shows the Terraform version. The purpose of this subcommand is to show the installed version of Terraform.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"3_Initialise_Infrastructure_Commands\"><\/span><b>3. Initialise Infrastructure Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>terraform Init:<\/strong> It commands let the tool initiate the working directory.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>terraform init \u2013input=true:<\/strong> It is the command to ask for valid input if the code demands it.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>terraform init \u2013lock=false:<\/strong> It is the command that is run to disable the locking of state files during the dedicated operations.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"4_Get_Commands\"><\/span><b>4. Get Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><strong>terraform get:<\/strong><span style=\"font-weight: 400;\"> It is the command to allow the tool to download and update the existing modules within the root.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform get \u2013update=true:<\/strong> It is the command under which the downloaded modules will be checked for available updates. If found, then those modules will be updated.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"5_Provision_Infrastructure_Commands\"><\/span><b>5. Provision Infrastructure Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>terraform plan:<\/strong> It is the command that works on creating an execution plan and implementing a DRY RUN.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>terraform plan \u2013out=path:<\/strong> This command saves the created plan in the form of a file.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform plan-destroy:<\/strong> This command derives a destroy plan for the selected resources.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply:<\/strong> This command is meant to implement the required changes to the existing infrastructure.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply- auto-approve:<\/strong> With this command, the changes made to the infrastructure will be implemented without any prompts.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply \u2013refresh=true:<\/strong> This command is meant to update the resource states before the execution of the plan and applying the changes.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply \u2013input=false:<\/strong> It is meant to request input of variables if they are not directly set.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply \u2013var \u2018foo=bar\u2019:<\/strong> This command allows you to set a multi-use variable within the configuration.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply \u2013var-file=foo:<\/strong> This command is used for specifying files consisting of key-value pairs for the values that are variable.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform apply \u2013target:<\/strong> This command is meant to apply or deploy the planned changes to the selected resources.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform destroy \u2013auto-approve:<\/strong> With this command, the resource will be deleted or destroyed without any prompts.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform destroy\u2013 target:<\/strong> With this command, you can target specific resources or dependencies that are meant to be destroyed.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"6_Terraform_Workspace_Commands\"><\/span><b>6. Terraform Workspace Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform workspace new:<\/strong> This command will allow you to create a new workspace and select it for further operations.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform workspace select:<\/strong> This command will allow you to select an existing workspace.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform workspace list:<\/strong> This command will display the list of all existing workspaces.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform workspace show:<\/strong> With this command, the name of the current workspace will be shown on the screen.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform workspace delete:<\/strong> It is meant to delete any empty workspace that you target.<\/span><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-78350\" src=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet.png\" alt=\"Terraform Workflow\" width=\"2240\" height=\"1260\" srcset=\"https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet.png 2240w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-300x169.png 300w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-1024x576.png 1024w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-768x432.png 768w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-1536x864.png 1536w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-2048x1152.png 2048w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-747x420.png 747w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-640x360.png 640w, https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Terraform-Cheat-Sheet-681x383.png 681w\" sizes=\"(max-width: 2240px) 100vw, 2240px\" \/><\/p>\n<h3><span class=\"ez-toc-section\" id=\"7_Format_and_Validate_Terraform_Command_or_Code\"><\/span><b>7. Format and Validate Terraform Command or Code<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform fmt:<\/strong> This is the formatting command based on the HCL canonical standard.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform validate:<\/strong> With this command, you get the potential to validate the configuration files for their use in the form of syntax.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"8_Inspect_Infrastructure_Commands\"><\/span><b>8. Inspect Infrastructure Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform graph:<\/strong> This command creates a graph listing all resources within the configuration.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform output:<\/strong> This command lists the root module outputs.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform output instance_public_ip:<\/strong> With this command, you can call for a listing of any specific output.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform output \u2013json:<\/strong> It is meant to list the outputs, particularly in JSON format.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform show:<\/strong> This command can access the plan or state file to provide a human-readable or understandable output.<\/span><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"9_Terraform_Import_Commands\"><\/span><b>9. Terraform Import Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Terraform import aws_instance.foo i-xyz123: This command is meant to import an AWS instance of a specific ID. In this sample command, the ID is i-xyz123. It will be imported onto the aws_instance resource that is named \u2018foo\u2019.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"10_Terraform_State_Manipulation_Commands\"><\/span><b>10. Terraform State Manipulation Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state list:<\/strong> It is meant to display all the resources in the form of a list within the state file.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state list aws_instance.my_ec2:<\/strong> The resource name that you input within this command will be the only one to be listed.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state mv:<\/strong> This command can be used for moving any specific item to the state file.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state rm:<\/strong> This command is meant to remove items from the selected state file.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state pull:<\/strong> This command will pull the current state file and output to stdout.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state push:<\/strong> This command is meant to update any remote state from any of the local state files.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state show aws_instance.my_ec2:<\/strong> It is meant to show the detailed attributes of a single resource.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform state refresh:<\/strong> It is meant to refresh the state file.<\/span><\/li>\n<\/ul>\n<blockquote><p>Read more on <a href=\"https:\/\/www.whizlabs.com\/blog\/terraform-vs-cloudformation-vs-ansible\/\">Terraform vs CloudFormation vs Ansible<\/a> today!<\/p><\/blockquote>\n<h3><span class=\"ez-toc-section\" id=\"11_Terraform_Miscellaneous_Commands\"><\/span><b>11. Terraform Miscellaneous Commands<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Echo \u201c1+5\u201d| terraform console:<\/strong> This command is used to display a predicted result of any of the expressions as an output.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform taint aws_instance.my_ec2:<\/strong> It marks a particular resource as tainted. As a result of which it is forced to be destroyed and recreated in the next APPLY run.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform untaint aws_instance.my_ec2:<\/strong> The taint mark on the resource is removed with this command.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform force-unlock LOCK_ID:<\/strong> The lock upon the state file of the ongoing configuration is removed.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform login:<\/strong> This command will get and save API tokens from the cloud.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><strong>Terraform logout:<\/strong> This command will remove all the stored credentials during the login process.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><b>Conclusion<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p dir=\"ltr\">This Terraform cheat sheet has covered almost all of the major commands used within Terraform for conducting different operations and accessing diverse functionalities across init, provisioning, state management, and workspaces. There&#8217;s a lot to explore and master within Terraform, and all you need is a solid reference to lean on while you&#8217;re starting. This cheat sheet is intended to be exactly that: a working reference you can return to as you build real infrastructure with Terraform.<\/p>\n<p dir=\"ltr\">Once these commands start feeling familiar, the natural next step is putting that knowledge to the test. Whizlabs offers hands-on labs where you can practice these exact commands in a real environment, along with a <a href=\"https:\/\/www.whizlabs.com\/hashicorp-certified-terraform-associate\/\" target=\"_blank\" rel=\"noopener sponsored\" data-schema-attribute=\"about mentions\">HashiCorp Certified Terraform Associate course and practice tests<\/a> to help you turn day-to-day command fluency into a certification you can put on your resume. Whether you&#8217;re bookmarking this cheat sheet for quick reference or actively working toward the Terraform Associate exam, the right mix of practice and structured preparation is what takes you from knowing the commands to actually mastering them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Aspiring to become a Terraform expert? Check out this exclusive Terraform cheat sheet that will help you become a Terraform pro! Terraform is a productive tool that came out in 2014. It is quite essential for describing a complete infrastructure of an application or software through integrated measures. Certain commands and code are commonly used within the tool for specific functions.\u00a0 Beginners might experience a tough time mastering the commands and sub-commands of Terraform. This IaC tool is highly intuitive, and to get the best out of it, you will need to keep in mind the basic commands that are [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":78351,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1862],"tags":[],"class_list":["post-78348","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",2240,1260,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-150x150.png",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-300x169.png",300,169,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-768x432.png",768,432,true],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-1024x576.png",1024,576,true],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-1536x864.png",1536,864,true],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-2048x1152.png",2048,1152,true],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",24,14,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",48,27,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",96,54,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",150,84,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",300,169,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12-250x250.png",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",640,360,false],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",96,54,false],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2021\/04\/Blog-12.png",150,84,false]},"uagb_author_info":{"display_name":"Pavan Gumaste","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/pavan\/"},"uagb_comment_info":9,"uagb_excerpt":"Aspiring to become a Terraform expert? Check out this exclusive Terraform cheat sheet that will help you become a Terraform pro! Terraform is a productive tool that came out in 2014. It is quite essential for describing a complete infrastructure of an application or software through integrated measures. Certain commands and code are commonly used&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/78348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=78348"}],"version-history":[{"count":6,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/78348\/revisions"}],"predecessor-version":[{"id":101814,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/78348\/revisions\/101814"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/78351"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=78348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=78348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=78348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}