github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/examples/digitalocean/main.tf (about) 1 provider "digitalocean" { 2 # You need to set this in your .bashrc 3 # export DIGITALOCEAN_TOKEN="Your API TOKEN" 4 # 5 } 6 7 resource "digitalocean_droplet" "mywebserver" { 8 # Obtain your ssh_key id number via your account. See Document https://developers.digitalocean.com/documentation/v2/#list-all-keys 9 ssh_keys = [12345678] # Key example 10 image = "${var.ubuntu}" 11 region = "${var.do_ams3}" 12 size = "512mb" 13 private_networking = true 14 backups = true 15 ipv6 = true 16 name = "mywebserver-ams3" 17 18 provisioner "remote-exec" { 19 inline = [ 20 "export PATH=$PATH:/usr/bin", 21 "sudo apt-get update", 22 "sudo apt-get -y install nginx", 23 ] 24 25 connection { 26 type = "ssh" 27 private_key = "${file("~/.ssh/id_rsa")}" 28 user = "root" 29 timeout = "2m" 30 } 31 } 32 } 33 34 resource "digitalocean_domain" "mywebserver" { 35 name = "www.mywebserver.com" 36 ip_address = "${digitalocean_droplet.mywebserver.ipv4_address}" 37 } 38 39 resource "digitalocean_record" "mywebserver" { 40 domain = "${digitalocean_domain.mywebserver.name}" 41 type = "A" 42 name = "mywebserver" 43 value = "${digitalocean_droplet.mywebserver.ipv4_address}" 44 }