Created
September 10, 2017 19:59
-
-
Save ivansostarko/6821384f336435d9ad87b221a7a9882a to your computer and use it in GitHub Desktop.
Terraform - Digital Ocean Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############### CONFIG ################################### | |
provider "digitalocean" { | |
token = "YOUR-TOKEN-HERE" | |
} | |
############### VMs ################################### | |
resource "digitalocean_droplet" "web" { | |
image = "centos-7-x64" | |
name = "webserver-1" | |
region = "fra1" | |
size = "2gb" | |
ipv6 = true | |
private_networking = true | |
volume_ids = ["${digitalocean_volume.storage.id}"] | |
} | |
############### STORAGE ################################### | |
resource "digitalocean_volume" "storage" { | |
region = "fra1" | |
name = "storage" | |
size = 40 | |
description = "Web Storage" | |
} | |
############### NETWORK ################################### | |
resource "digitalocean_floating_ip" "network" { | |
droplet_id = "${digitalocean_droplet.web.id}" | |
region = "${digitalocean_droplet.web.region}" | |
} | |
############### DNS ################################### | |
resource "digitalocean_domain" "dns" { | |
name = "example.com" | |
ip_address = "${digitalocean_droplet.web.ipv4_address}" | |
} | |
############### DNS ZONES ################################### | |
resource "digitalocean_record" "dns_zone" { | |
domain = "domain.com" | |
type = "TXT" | |
name = "name" | |
value = "value" | |
} | |
resource "digitalocean_record" "dns" { | |
domain = "domain.com" | |
type = "TXT" | |
name = "domain.com" | |
value = "value" | |
} | |
############### FIREWALL ################################### | |
resource "digitalocean_firewall" "web" { | |
name = "only-22-80-and-443" | |
droplet_ids = ["${digitalocean_droplet.web.id}"] | |
inbound_rule = [ | |
{ | |
protocol = "tcp" | |
port_range = "22" | |
source_addresses = ["192.168.1.0/24", "2002:1:2::/48"] | |
}, | |
{ | |
protocol = "tcp" | |
port_range = "80" | |
source_addresses = ["0.0.0.0/0", "::/0"] | |
}, | |
{ | |
protocol = "tcp" | |
port_range = "443" | |
source_addresses = ["0.0.0.0/0", "::/0"] | |
}, | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment