Terraform is an open-source infrastructure as code (IaC) tool developed by HashiCorp. It allows you to define, provision, and manage infrastructure using a declarative configuration language called HashiCorp Configuration Language (HCL), although JSON is also supported. Terraform is cloud-agnostic, meaning it can be used to manage infrastructure across multiple providers like AWS, Azure, Google Cloud, and on-premise environments.
Providers: Plugins that enable Terraform to interact with cloud providers (AWS, Azure, etc.) or other APIs. Each provider offers a set of resources and data sources.
Resources: The key elements of your infrastructure, such as virtual machines, storage, networking components, etc.
Modules: A way to group related resources together, often used for reusability.
State: Terraform keeps track of the infrastructure it manages in a state file, which helps in making incremental changes to resources.
Plan: The terraform plan
command shows the changes that will be made to the infrastructure.
Apply: The terraform apply
command is used to execute the plan and apply changes to the infrastructure.
Destroy: The terraform destroy
command removes all the infrastructure that is managed by the current state.
Write configuration: You describe your infrastructure using HCL files.
Initialize: Run terraform init
to download the necessary provider plugins.
Plan: Run terraform plan
to see the changes that will be applied.
Apply: Run terraform apply
to make the desired changes to your infrastructure.
Manage state: Terraform will update its state file after each apply.