Table of contents
Terraform Commands
1. terraform init
The terraform init
command initializes a working directory containing Terraform configuration files. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control.
2. terraform init -upgrade
The -upgrade
option for the terraform init
command is used to upgrade modules and plugins. This can be useful if you want Terraform to ignore the dependency lock file and consider installing newer versions.
3. terraform plan
The terraform plan
command creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure. By default, when Terraform creates a plan it reads the current state of any already-existing remote objects to make sure that the Terraform state is up-to-date
4. terraform apply
The terraform apply
command is used to deploy your infrastructure according to the configuration files or a pre-determined execution plan. It can perform changes to the real infrastructure environment or the desired state of the configuration
5. terraform validate
The terraform validate
command checks the syntax and internal consistency of Terraform configuration files in a directory. It does not access any remote services or state files.
6. terraform fmt
The terraform fmt
command is used to rewrite Terraform configuration files to a canonical format and style which it easier to maintain & read.
7. terraform show
The terraform show
command inspects the state file and displays the resource details.
8. terraform destroy
The terraform destroy
command to delete the resources created using the apply command. The destroy command is an essential part of the Terraform workflow, allowing users to clean up resources that are no longer needed.
9. terraform refresh
The terraform refresh
command is used to reconcile the Terraform state with the actual infrastructure resources. It updates the state file with the current state of the resources without making any changes to the infrastructure.
10. terraform state show
The terraform state show
command is used to show the attributes of a single resource in the Terraform state.
11. terraform providers
The terraform providers
command prints information about the providers required in the current configuration.
12. terraform output
The terraform output
command print value of all output variables defined in all the files in the current configuration directory.
Terraform’s main competitors
Ansible
Ansible is an open-source automation tool that supports infrastructure provisioning and configuration management. Ansible uses YAML-based playbooks for managing infrastructure. Ansible is known for its agentless architecture and its ability to automate tasks across multiple platforms.
AWS CloudFormation
AWS CloudFormation is a native infrastructure provisioning tool provided by Amazon Web Services (AWS). It allows users to define infrastructure resources and their dependencies using YAML or JSON templates. CloudFormation integrates seamlessly with other AWS services and provides a declarative approach to infrastructure provisioning within the AWS ecosystem.
Puppet
Puppet is a popular open-source Infrastructure provisioning tool. It uses declarative language to define system configurations and automate the deployment and management of software and infrastructure. Puppet supports various operating systems and provides a centralized management platform.
Chef
Chef is an open-source tool that follows a model-driven approach to Configuration Management. It uses a domain-specific language (DSL) called Chef Infra to define system configurations and automate the provisioning and management of infrastructure. Chef offers flexibility and supports multiple platforms and cloud providers.
Kubernetes
Kubernetes Infrastructure as Code (IaC) refers to the practice of using declarative configuration files to define and manage Kubernetes infrastructure. With Kubernetes IaC, infrastructure resources such as pods, services, deployments, and ingress rules are defined in YAML or JSON files.
Packer
Packer Infrastructure as Code (IaC) involves using declarative configuration files to define and automate the creation of machine images across multiple platforms. Packer allows you to define image templates using JSON or HCL configuration files.
Conclusion
In this blog, we have seen about some terraform commands and its competitors.
Hope you find it helpful🤞 Let me know in the comment section👇 about your learning experience.✨
👆The information presented above is based on my interpretation. Suggestions are always welcome.😊
~Smriti Sharma✌