Terraform is an orchestration tool that will bootstrap, initialize resources and can start a configuration management tool
Terraform is not a configuration management tool Using provisioners, Terraform enables any configuration management tool to be used to setup a resource once it has been created.
choco install terraform
terraform version
Terraform v0.12.1
Terraform configurations can contain multiple resources, multiple resource types, and these types can even span multiple providers.
provider "aws" {
access_key = "ACCESS_KEY_HERE"
secret_key = "SECRET_KEY_HERE"
region = "us-east-1"
}
Each “Provider” is its own encapsulated binary distributed separately from Terraform itself.
The resource block defines a resource that exists within the infrastructure.
resource "aws_instance" "example" {
ami = "ami-2757f631"
instance_type = "t2.micro"
}
where:
Terraform wrote some data into the terraform.tfstate file.
terraform show shows the current state
This state file is extremely important; it keeps track of the IDs of created resources so that Terraform knows what it is managing.
This file must be saved and distributed to anyone who might run Terraform.
It is generally recommended to setup remote state when working with Terraform, to share the state automatically.
Every Terraform setup has two parts:
init:
used after:
terraform init
terraform plan
terraform apply
The output format is similar to the diff format generated by tools such as Git.
terraform show
inspect the current state
terraform destroy