Digital Ocean Example.

* Added Readme for this example.

* Base Terraform Digital Ocean Files

* Update Readme to read better

*  Changes to be committed:
	modified:   README.md
This commit is contained in:
Michael D Roach 2016-05-09 03:04:51 -04:00 committed by Paul Stack
parent fe6fff3a20
commit 465a838f91
4 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# Digital Ocean Droplet launch and setting the Domain records at Digital ocean.
The example launches a Ubuntu 14.04, runs apt-get update and installs nginx. Also demostrates how to create DNS records under Domains at DigitalOcean.
To run, configure your Digital Ocean provider as described in https://www.terraform.io/docs/providers/digitalocean/index.html
## Prerequisites
You need to export you DigitalOcean API Token as an environment variable
export DIGITALOCEAN_TOKEN="Put Your Token Here"
## Run this example using:
terraform plan
terraform apply

View File

@ -0,0 +1,43 @@
provider "digitalocean" {
# You need to set this in your .bashrc
# export DIGITALOCEAN_TOKEN="Your API TOKEN"
#
}
resource "digitalocean_droplet" "mywebserver" {
# Obtain your ssh_key id number via your account. See Document https://developers.digitalocean.com/documentation/v2/#list-all-keys
ssh_keys=[12345678] # Key example
image = "${var.ubuntu}"
region = "${var.do_ams3}"
size = "512mb"
private_networking = true
backups = true
ipv6 = true
name = "mywebserver-ams3"
provisioner "remote-exec" {
inline = [
"export PATh=$PATH:/usr/bin",
"sudo apt-get update",
"sudo apt-get -y install nginx"
]
connection {
type = "ssh"
key_file = "file(${HOME}/.ssh/id_rsa)"
user = "root"
timeout = "2m"
}
}
}
resource "digitalocean_domain" "mywebserver" {
name = "www.mywebserver.com"
ip_address = "${digitalocean_droplet.mywebserver.ipv4_address}"
}
resource "digitalocean_record" "mywebserver" {
domain = "${digitalocean_domain.mywebserver.name}"
type = "A"
name = "mywebserver"
value = "${digitalocean_droplet.mywebserver.ipv4_address}"
}

View File

@ -0,0 +1,7 @@
output "Public ip" {
value = "${digitalocean_droplet.mywebserver.ipv4_address}"
}
output "Name" {
value = "${digitalocean_droplet.mywebserver.name}"
}

View File

@ -0,0 +1,71 @@
# ####
# Current Availiable Datacenter Regions
# As of 05-07-2016
#
variable "do_ams2" {
description = "Digital Ocean Amsterdam Data Center 2"
default = "ams2"
}
variable "do_ams3" {
description = "Digital Ocean Amsterdam Data Center 3"
default = "ams3"
}
variable "do_fra1" {
description = "Digital Ocean Frankfurt Data Center 1"
default = "fra1"
}
variable "do_lon1" {
description = "Digital Ocean London Data Center 1"
default = "lon1"
}
variable "do_nyc1" {
description = "Digital Ocean New York Data Center 1"
default = "nyc1"
}
variable "do_nyc2" {
description = "Digital Ocean New York Data Center 2"
default = "nyc2"
}
variable "do_nyc3" {
description = "Digital Ocean New York Data Center 3"
default = "nyc3"
}
variable "do_sfo1" {
description = "Digital Ocean San Francisco Data Center 1"
default = "sfo1"
}
variable "do_sgp1" {
description = "Digital Ocean Singapore Data Center 1"
default = "sgp1"
}
variable "do_tor1" {
description = "Digital Ocean Toronto Datacenter 1"
default = "tor1"
}
# Default Os
variable "ubuntu" {
description = "Default LTS"
default = "ubuntu-14-04-x64"
}
variable "centos" {
description = "Default Centos"
default = "centos-72-x64"
}
variable "coreos" {
description = "Defaut Coreos"
default = "coreos-899.17.0"
}