Git Product home page Git Product logo

terraform-workshop's People

Contributors

samber avatar

Watchers

 avatar  avatar

Forkers

dsmith73

terraform-workshop's Issues

Until step 13

# export TF_VAR_do_token="qwertyuiop"
variable "do_token" {}

variable "region" { default = "lon1" }

provider "digitalocean" {
  token = "${var.do_token}"
}

resource "digitalocean_droplet" "webs" {
  image  = "docker-16-04"
  name   = "web-${terraform.workspace}-${count.index}"
  region = "${var.region}"
  size   = "512mb"

  count = 2

  ssh_keys = [
    "11:f4:d8:2d:c0:6a:a7:73:2d:6e:c4:5e:5c:1c:71:e0"
  ]

  provisioner "remote-exec" {
    inline = [
      "docker run -d -p 8080:80 -h $(hostname) iadvize/hello-world"
    ]
  }

}

resource "digitalocean_loadbalancer" "front_lb" {
  name = "webs-loadbalancer-${terraform.workspace}"
  region = "${var.region}"

  forwarding_rule {
    entry_port = 8080
    entry_protocol = "http"

    target_port = 8080
    target_protocol = "http"
  }

  healthcheck {
    port = 8080
    protocol = "http"
    path = "/"
  }

  droplet_ids = ["${digitalocean_droplet.webs.*.id}"]
}

output "ipv4" { value = "${digitalocean_droplet.webs.*.ipv4_address}" }
output "lb" { value = "${digitalocean_loadbalancer.front_lb.ip}" }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.