Terraform Classroom Series – 17/Sep/2019

Terraform Setup

  1. Install Terraform:
    • Windows: choco install terraform -y
    • Other:
    • Install Visual Studio Code
    • Add Terraform Extension to Visual Studio Code

Basics of Terraform DSL

  • Input for terraform is folder/directory
  • Terraform will pick all the files in the input folder with *.tf
  • Provider Syntax
provider "<provider name>" {
    arg1    = value1
    ...
    ...
    argn    = valuen
}
####### Example ###########

provider "aws" {
    region      = "us-west-2"
    secret_key  = "jkdsahfkjadsfhkjasdfhdkjahfdakj"
    access_key  = "kjsdhfkjsdfkjhdsf"
}
  • Resources Syntax
resource "<resource type>" "<your name for this resource>" {
    arg1    = value1
    ...
    ...
    argn    = valuen
}

############### Example ###############

resource "aws_instance" "mywebserver" {
    ami             = "<ami id>"
    instance_type   = "t2.micro"
}

Execution Steps

  1. Create a directory with name "hello-aws"
  2. create a file inside directory "hello-aws" named "main.tf" with above contents
terraform init <dirpath of hello-aws>
terraform validate <dirpath of hello-aws>
terraform apply <dirpath of hello-aws>

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube