Terraform provides a set of commands to manage your infrastructure and perform various tasks.
in this article we are listing the top 10 commonly used Terraform commands.
terraform init
Initializes a new or existing Terraform configuration. It downloads provider plugins and initializes the working directory.
terraform plan
Generates an execution plan that shows what Terraform will do when you apply your configuration. This is a dry run and helps you understand the changes Terraform will make.
terraform apply
Applies the changes described in your Terraform configuration to your infrastructure. It creates, updates, or deletes resources as needed.
terraform destroy
Destroys all resources created by Terraform in your configuration. Use with caution, as it can lead to data loss and service disruption.
terraform validate
Checks the validity of your Terraform configuration files. It ensures that the syntax is correct and references to resources are valid.
terraform fmt
Rewrites Terraform configuration files to a canonical format. This command helps maintain consistent code formatting.
terraform show
Displays the current state or plan in a human-readable format. It can be useful for reviewing the details of your infrastructure.
terraform refresh
Updates the state file with the real-world resources that exist in your infrastructure. This is useful if changes were made outside of Terraform's control.
terraform state
Provides advanced state management functionality. You can use this command to inspect, modify, or remove items from the state file.
terraform import
Imports existing infrastructure into Terraform. It allows you to manage existing resources using Terraform.
Top comments (4)
Excellent!
thanks, glad you like it
great article as always
good explanation