Terraform Bootstrap

This blog is in two parts. This first part explains what is needed to start with Terraform, the second part is to go one step further but still targets beginners.

Table of content

Terraform bare minimum

Terraform, what is it ?

  • Terraform allows to manage infrastructure thanks to the configuration file known as infrastructure as Code (IaC). It allows to create reproducible infrastructure.
  • Terraform determines what has changed and creates incremental execution plans that respect dependencies. It is idempotent.

What do I need to provision something with Terraform ?

How do I know what to create ?

Most of the time you need the documentation of the provider you want to use. The documentation often respect the same structure and it’s easy to browse. These are the main providers that I use NSX-T/ACI/AWS

The configuration is made of 3 blocks

Block Description
Terraform What provider to use
Provider Where to push the configuration
Resources What to create
terraform provider{
    required_provider{
        aws = {
            source  = "hashicorp/aws"
            version = "3.55.0"
        }
    }
}

provider "aws" {
    region = "us-east-2"
    access_-_key = "**********"
    secret_key = "**********"
}

resource "aws_s3_bucket" "netmemo_bucket" {
    bucket = "netmemo_bucket"
}

You need 2 commands to push your first configuration

When the first initialization has been done, you will only need the apply command for the next infrastructure modifications.

  • terraform init => Download and configure the provider
  • terraform apply => It tells you what it will do then push the configuration

Proxy white listing

In enterprise, don’t forget to whitelist URLs. Below is an example for AWS.

DEMO TIME

Related