Hashicorp Terraform Associate Certification

Terraform is a IAC

Useful Links:

# Provider Terraform provides multiple providers 1984 providers, 8864 modules & counting – 09/04/2022

Whenever you add a provider, we need to run terraform init so that it’ll download the associated plugins Every time when we run terraform init, it’ll download the associated plugins and save it in the folder where command is executed

TERRAFORM {
  REQUIRED_PROVIDERS {
    AWS = {
      SOURCE = "HASHICORP/AWS"
      VERSION = "~> 3.0"
    }
    AZURERM = {
      SOURCE  = "HASHICORP/AZURERM"
      VERSION = "=3.0.0"
    }
  }
}

The code above will download the aws and azure providers to the location where the command will be run

image.png

Attributes & Output Values: Terraform can output the attributes(details) of the resources(ec2,s3 etc..) created We can reference the attributes as input to other values in terraform code Ex – If we need to see IP address of EC2 Instance created, we can use output section in terraform code.

RESOURCE "AWS_EIP" "LB" {
  VPC = TRUE
}

OUTPUT "EIP" {
  VALUE = AWS_EIP.LB.PUBLIC_IP
}

RESOURCE "AWS_S3_BUCKET" "S3" {
  BUCKET = "TF_S3_179"
}

OUTPUT "S3_NAME" {
  VALUE = AWS_S3_BUCKET.S3.BUCKET_DOMAIN_NAME
}

TERRAFORM PLAN image.png TERRAFORM APPLY image.png