Terraform Workshop

Terraform Workshop

Intro to Terraform workshop I gave for the Hacker Garage Community day 2017

A0574e5093df6afd68f1c109c5a9bf22?s=128

Orlando Del Aguila

March 11, 2017
Tweet

Transcript

  1. Terraform Workshop Orlando Del Aguila Hash U

  2. @orlando @eatcodetravel @eatcodetravel eatcodetravel.com

  3. www.hashlabs.com

  4. Overview

  5. Commands

  6. 1. Init 2. Version 3. Get 4. Plan 5. Apply

  7. Providers

  8. Terraform / Provider provider "heroku"{ email = "orlando@orlandodelaguila.com" api_key =

    "my api key" }
  9. Resources

  10. Terraform / Resources resource "heroku_app" "example" { name = "my-super-heroku-app"

    region = "us" }
  11. Data Sources

  12. Terraform / Data sources data "aws_ami" "ubuntu" { most_recent =

    true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-*"] } } resource "aws_instance" "example" { ami = "${data.aws_ami.ubuntu.id}" instance_type = "t2.micro" }
  13. Variables

  14. Terraform / Variables variable “app_name" { default = “my-super-app-tf“ }

    
 variable "heroku" { default = { email = “orlando@orlandodelaguila.com" api_key = “123123" } } variable "list" { default = [“first”,”second”] }
  15. Variable Interpolation

  16. Terraform / Variables data "aws_ami" "ubuntu" { most_recent = true

    filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-*"] } } resource "aws_instance" "example" { ami = "${data.aws_ami.ubuntu.id}" instance_type = "t2.micro" }
  17. Interpolation functions

  18. Terraform / Functions resource "heroku_app" "example" { name = "${uuid()}"

    region = "us" }
  19. Output Variables

  20. Terraform / Functions output "git_url" "example" { value = "${heroku_app.example.git_url}"

    }
  21. Modules

  22. Terraform / Modules variable "app_name" {} module "app"{ source =

    "./heroku_app" app_name = "${var.app_name}" region = "us" }
  23. State

  24. Terraform / Modules https://gist.github.com/orlando/ 2fe57ff440d88655732008d731e3be02

  25. Hands on

  26. 1. Install Terraform 2. Clone repository 3. Heroku account 4.

    Heroku API key 5. Terraform.tfvars