Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Terraform Workshop

Terraform Workshop

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

Orlando Del Aguila

March 11, 2017
Tweet

More Decks by Orlando Del Aguila

Other Decks in Programming

Transcript

  1. Terraform
    Workshop
    Orlando Del Aguila
    Hash U

    View Slide

  2. @orlando
    @eatcodetravel
    @eatcodetravel
    eatcodetravel.com

    View Slide

  3. www.hashlabs.com

    View Slide

  4. Overview

    View Slide

  5. Commands

    View Slide

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

    View Slide

  7. Providers

    View Slide

  8. Terraform / Provider
    provider "heroku"{
    email = "[email protected]"
    api_key = "my api key"
    }

    View Slide

  9. Resources

    View Slide

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

    View Slide

  11. Data Sources

    View Slide

  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"
    }

    View Slide

  13. Variables

    View Slide

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

    variable "heroku" {
    default = {
    email = “[email protected]"
    api_key = “123123"
    }
    }
    variable "list" {
    default = [“first”,”second”]
    }

    View Slide

  15. Variable Interpolation

    View Slide

  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"
    }

    View Slide

  17. Interpolation functions

    View Slide

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

    View Slide

  19. Output Variables

    View Slide

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

    View Slide

  21. Modules

    View Slide

  22. Terraform / Modules
    variable "app_name" {}
    module "app"{
    source = "./heroku_app"
    app_name = "${var.app_name}"
    region = "us"
    }

    View Slide

  23. State

    View Slide

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

    View Slide

  25. Hands on

    View Slide

  26. 1. Install Terraform
    2. Clone repository
    3. Heroku account
    4. Heroku API key
    5. Terraform.tfvars

    View Slide