Apply for invite to IaCP

The Terraform TemplateΒΆ

Page 2 of 8

Create the Terraform template in VCS

../_images/devops_flow_1.png

Important

This step is done in the VCS system.

  1. The Terraform template must be in a git repo

  2. This example contains 2 files, main.tf and variables.tf as shown below

  3. Create a new repo in your VCS account and add these 2 files with the contents shown below.

main.tf defines the resources and the provider.

provider "aws" {
  region     = var.region
}

data "aws_ami" "the_ami" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

resource "aws_instance" "scalr" {
  ami                    = data.aws_ami.the_ami.id
  instance_type          = "t2.nano"
}

variables.tf

variable "region" {
  description = "Region"
}