Terraform for DevOps Engineers

terraform commands

Essential Terraform Commands:

  • terraform init: Initializes a new Terraform project, downloading necessary plugins and setting up the configuration.

  • terraform plan: Creates an execution plan, outlining the proposed changes to your infrastructure.

  • terraform apply: Applies the changes outlined in the execution plan, creating or modifying resources.

  • terraform destroy: Destroys the infrastructure defined in the configuration.

Additional Useful Commands:

  • terraform output: Displays the values of defined outputs.

  • terraform workspace: Manages Terraform workspaces for different environments.

  • terraform state: Interacts with the Terraform state file, which stores the current infrastructure configuration.

  • terraform taint: Marks a resource as tainted, requiring manual intervention for changes.

  • terraform untaint: Removes the taint from a resource.

  • terraform import: Imports existing infrastructure into Terraform management.

  • terraform refresh: Updates the state file with the current state of the infrastructure.

  • terraform show: Displays the current state of the infrastructure.

  • terraform validate: Validates the syntax and structure of the configuration.