Quick TerraForm

Posted on October 2, 2021
Tags: aws

TerraForm is declarative, apply is idempotent


terraform {
    required_providers {
        aws = {
            source = "hashicorp/aws"
            version = "~> 3.0"
        }
    }
}

provider "aws" {
    region = "us-east-1"
}

resource "aws_instance" "example" {
    ami = "ami-05fa00d4c63e32376"
    instance_type = "t2.micro"
}
terraform init #downloads the terraform modules
terraform plan #query aws API and see what will be deployed and its settings
terraform apply #starts the instance in aws
terraform destroy

1 keywords

2 Theory

├── main.tf
├── .terraform
│   └── providers
│       └── registry.terraform.io
│           └── hashicorp
│               └── aws
│                   └── 3.75.2
│                       └── linux_amd64
│                           └── terraform-provider-aws_v3.75.2_x5
├── .terraform.lock.hcl
├── terraform.tfstate
└── terraform.tfstate.backup