AWS — Infrastructure as Code Tutorial — Step 1.2 — Terraform

Getting started

  • Terraform configuration file- which is called a module — needs to have .tf extension
  • Terraform is using its own configuration language — HCL. While it is possible to use json format also — we will use Terraform’s own language.
  • Text and image bellow are from the link above.
  • Blocks are containers for other content and usually represent the configuration of some kind of object, like a resource. Blocks have a block type, can have zero or more labels, and have a body that contains any number of arguments and nested blocks. Most of Terraform’s features are controlled by top-level blocks in a configuration file.
  • Arguments assign a value to a name. They appear within blocks.
  • Expressions represent a value, either literally or by referencing and combining other values. They appear as values for arguments, or within other expressions.
  • Resources — remember, just like in CloudFormation template, it is the only required section.
  • Just like in CloudFormation template resource AWS::EC2::VPC — the resource we want to create — “aws_vpc

Preparing Terraform

  • Terraform detected we were deploying to AWS.
  • Terraform downloaded the provider binary (plugin).
  • Terraform downloaded selections.json, which contains a hash value that is used to test the binary integrity.

Moving on …

Running “terraform apply”

Validating resource creation — “terraform show”

Deleting resource — terraform destroy

Summary:

  • Several details about Terraform language: HCL syntax and structure. Read more about HCL
  • How Terraform detects where we want to deploy resources and that it downloads the corresponding provider plugin. We checked afterwards which files were downloaded and what are they used for.
  • How Terraform does validation of configuration file syntax.
  • How Terraform deploys (applies), lists and destroys configuration.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store