Terraform Commands Cli



  • You can pass also a directory like parameters without it will run in the local dir
  • The dir argument can also be a module source. In this case, apply behaves as though init


This command accepts all the arguments and flags that the apply command accepts, with the exception of a plan file argument.
If -force is set, then the destroy confirmation will not be shown.
can be previewed at any time with an equivalent terraform plan -destroy


command is used to rewrite Terraform configuration files to a canonical format and style


command is used to download and update modules.
The modules are downloaded into a local .terraform folder. This folder should not be committed to version control.


command is used to generate a visual representation of either a configuration or execution plan
to convert the output in an image you need to install graphviz before

sudo apt-get install graphviz
terraform graph | dot -Tpng > graph.png


import existing resources

terraform import aws_instance.foo i-abcd1234

The current implementation of Terraform import can only import resources into the state. It does not generate configuration.
The command currently can only import one resource at a time. This means you can't yet point Terraform import to an entire collection of resources such as an AWS VPC and import all of it


command is used to initialize a Terraform configuration using another module as a skeleton.


command is used to extract the value of an output variable from the state file


performs a refresh, unless explicitly disabled, and then determines what actions are necessary to achieve the desired state specified in the configuration files


command uploads your Terraform configuration to be managed by HashiCorp's Atlas.
This Atlas seems a central point to manage terraform exspecially for teams


command is used to reconcile the state Terraform knows about (via its state file) with the real-world infrastructure.


it is possible integrate terraform with a remote repository so the state is saved there and you don't need to commit


command is used to provide human-readable output from a state or plan file


command is used for advanced state management. As your Terraform usage becomes more advanced, there are some cases where you may need to modify the Terraform state.


command manually marks a Terraform-managed resource as tainted, forcing it to be destroyed and recreated on the next apply.


command manually unmarks a Terraform-managed resource as tainted, restoring it as the primary instance in the state.


command is used to validate the syntax of the terraform files.

Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License