Terraform
an open-source infrastructure-as-code software tool created by HashiCorp.
Last updated
Was this helpful?
an open-source infrastructure-as-code software tool created by HashiCorp.
Last updated
Was this helpful?
Terraform is .
Terraform is made up of files in the (HCL) and follows a similar structure to JSON or YAML.
All Terraform files have the .tf
extension.
State files are how Terraform keeps track of what it deploys and where. You will NEVER edit the state files directly. They are all managed by Terraform, but you will need to direct Terraform where to deploy the files
State files are stored in a shared location where the deployment can get to them.
terraform {
backend "s3" {
bucket = "udacity-tf-tscotto"
key = "terraform/terraform.tfstate"
region = "us-east-2"
}
}hc
Terraform is made up of blocks. There are 4 types of blocks we will be using:
Provider blocks: define cloud providers
provider "aws" {
region = "us-east-2"
}
Resource blocks: define resources
resource "aws_instance" "aws_linux" {
ami = ami-074cce78125f09d61
count = var.instance_count // (2)
instance_type = t2.micro
tags = {
Name = "EC2 Instance"
}
}
Variable blocks: define variables
variable "instance_count" {
description = "The desired number of EC2 instances."
default = 2
}
Module blocks: define groups of reusable code