github.com/jdextraze/terraform@v0.6.17-0.20160511153921-e33847c8a8af/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  		connection {
    25  			type = "ssh"
    26  			key_file = "file(${HOME}/.ssh/id_rsa)"
    27  			user = "root"
    28  			timeout = "2m"
    29  		}
    30  	}
    31  }
    32  
    33  resource "digitalocean_domain" "mywebserver" {
    34  	name = "www.mywebserver.com"
    35  	ip_address = "${digitalocean_droplet.mywebserver.ipv4_address}"
    36  }
    37  
    38  resource "digitalocean_record" "mywebserver" {
    39  	domain = "${digitalocean_domain.mywebserver.name}"
    40  	type = "A"
    41  	name = "mywebserver"
    42  	value = "${digitalocean_droplet.mywebserver.ipv4_address}"
    43  }