Terraform Logo Documentation
Terraform
Getting Started
hashicorp.com/terraform/docs/guides/getting-started

Getting Started with Terraform

This guide walks you through installing and using Terraform to manage infrastructure programmatically using configuration files.

Installation and Setup

Terraform can run anywhere with a CLI or as part of your infrastructure automation tools. Follow these steps to install:

  1. Download the latest binary for your operating system from our downloads page
  2. Extract the archive file
  3. Add the terraform binary to your system PATH
  4. Verify the install with terraform --version
  5. Install required providers terraform init

Terraform is open source and available on GitHub at hashicorp/terraform.

Initial Configuration

Create a basic infrastructure configuration in main.tf:


provider "aws" {
  region = "us-west-2"
}

resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = "t2.micro"
  tags = {
    Name = "example-ec2"
  }
}

Run terraform apply to create your first infrastructure resource. This will provision an AWS instance in the configured region.

State Management

Terraform saves a state file showing the state of your infrastructure. This state file must be protected by encryption at rest and in transit. Use terraform state commands for inspection and management.

Apply this configuration

terraform apply

This command will output your resources and show exactly what infrastructure elements will be created.

Next Steps
  • Explore additional resources and providers
  • Read about workspaces for environment management
  • See how to apply infrastructure-as-code in your team workflow
Last updated 3 weeks ago by docs@hashicorp.com
```