- The validate command is used to validate/check the syntax of the Terraform files. A syntax check is done on all the Terraform files in the directory and will display an error if any of the files don’t validate. The syntax check does not cover every syntax common issues.
- Sonic Screwdriver is a multi-functional tool to manage AWS infrastructure. Its a swiss army knife type of tool and has a variety of uses. Mainly its focus is to automate mundane repetitive tasks into simple one line commands. With it you are able to debug environments and issues quickly.
- OpenStack Cheat-Sheet Common Router Volumes show help for command list routers list all volumes nova help command neutron routerlist nova volumelist neutron help command show router details show volume details etc. Neutron routershow subnetID nova volumeshow volumeID create a neutron router create a new volume.
Command-line-cheat-sheet A place to quickly lookup commands (bash, Vim, git, AWS, Docker, Terraform, Ansible, kubectl).
Hands-on: Try the Terraform: Get Started collection on HashiCorp Learn.
The command line interface to Terraform is via the
terraform
command, whichaccepts a variety of subcommands such as terraform init
or terraform plan
.A full list of all of the supported subcommands is in the navigation sectionof this page.We refer to the
terraform
command line tool as 'Terraform CLI' elsewherein the documentation. This terminology is often used to distinguish it fromother components you might use in the Terraform product family, such asTerraform Cloud orthe various Terraform providers, which are developed andreleased separately from Terraform CLI.To view a list of the commands available in your current Terraform version,run
terraform
with no additional arguments:(The output from your current Terraform version may be different than theabove example.)
To get specific help for any specific command, use the
-help
option with therelevant subcommand. For example, to see help about the 'validate' subcommandyou can run terraform validate -help
.The inline help built in to Terraform CLI describes the most importantcharacteristics of each command. For more detailed information, refer to eachcommand's section of this documentation, available in the navigationsection of this page.
» Switching working directory with -chdir
The usual way to run Terraform is to first switch to the directory containingthe
.tf
files for your root module (for example, using the cd
command), sothat Terraform will find those files automatically without any extra arguments.In some cases though — particularly when wrapping Terraform in automationscripts — it can be convenient to run Terraform from a different directory thanthe root module directory. To allow that, Terraform supports a global option
-chdir=...
which you can include before the name of the subcommand you intendto run:Terraform Commands Cheat Sheet Printable
The
chdir
option instructs Terraform to change its working directory to thegiven directory before running the given subcommand. This means that any filesthat Terraform would normally read or write in the current working directorywill be read or written in the given directory instead.There are two exceptions where Terraform will use the original working directoryeven when you specify
-chdir=...
:- Settings in the CLI Configuration are not for a specificsubcommand and Terraform processes them before acting on the
-chdir
option. - In case you need to use files from the original working directory as partof your configuration, a reference to
path.cwd
in the configuration willproduce the original working directory instead of the overridden workingdirectory. Usepath.root
to get the root module directory.
» Shell Tab-completion
If you use either
bash
or zsh
as your command shell, Terraform can providetab-completion support for all command names and (at this time) some commandarguments.To add the necessary commands to your shell profile, run the following command:
After installation, it is necessary to restart your shell or to re-read itsprofile script before completion will be activated.
To uninstall the completion hook, assuming that it has not been modifiedmanually in the shell profile, run the following command:
Currently not all of Terraform's subcommands have full tab-completion supportfor all arguments. We plan to improve tab-completion coverage over time.
» Upgrade and Security Bulletin Checks
The Terraform CLI commands interact with the HashiCorp serviceCheckpoint to check for the availabilityof new versions and for critical security bulletins about the current version.
One place where the effect of this can be seen is in
terraform version
, whereit is used by default to indicate in the output when a newer version isavailable.Only anonymous information, which cannot be used to identify the user or host,is sent to Checkpoint. An anonymous ID is sent which helps de-duplicate warningmessages. Both the anonymous id and the use of checkpoint itself are completelyoptional and can be disabled.
Checkpoint itself can be entirely disabled for all HashiCorp products bysetting the environment variable
CHECKPOINT_DISABLE
to any non-empty value.Alternatively, settings inthe CLI configuration file can be used todisable checkpoint features. The following checkpoint-related settings aresupported in this file:
disable_checkpoint
- set totrue
to disable checkpoint callsentirely. This is similar to theCHECKPOINT_DISABLE
environment variabledescribed above.disable_checkpoint_signature
- set totrue
to disable the use of ananonymous signature in checkpoint requests. This allows Terraform to checkfor security bulletins but does not send the anonymous signature in theserequests.
Terraform Commands Cheat Sheet 2020
The Checkpoint client code usedby Terraform is available for review by any interested party.