From db3879358476f6e9845f17e3c8cf6ba8a51ccde9 Mon Sep 17 00:00:00 2001 From: Nemo Date: Sat, 3 Feb 2018 13:06:19 +0530 Subject: [PATCH] Adds digital ocean droplet --- digitalocean/droplets.tf | 16 ++++++++++++++++ digitalocean/firewall.tf | 37 +++++++++++++++++++++++++++++++++++++ digitalocean/networking.tf | 4 ++++ main.tf | 4 ++++ providers.tf | 4 ++++ variables.tf | 1 + 6 files changed, 66 insertions(+) create mode 100644 digitalocean/droplets.tf create mode 100644 digitalocean/firewall.tf create mode 100644 digitalocean/networking.tf diff --git a/digitalocean/droplets.tf b/digitalocean/droplets.tf new file mode 100644 index 0000000..d5507bc --- /dev/null +++ b/digitalocean/droplets.tf @@ -0,0 +1,16 @@ +resource "digitalocean_droplet" "sydney" { + image = "" + name = "sydney.captnemo.in" + region = "blr1" + size = "1gb" + ipv6 = true + private_networking = true + resize_disk = true + + tags = [ + "bangalore", + "proxy", + "sydney", + "vpn", + ] +} diff --git a/digitalocean/firewall.tf b/digitalocean/firewall.tf new file mode 100644 index 0000000..1f42ad3 --- /dev/null +++ b/digitalocean/firewall.tf @@ -0,0 +1,37 @@ +resource "digitalocean_firewall" "web" { + name = "web-inbound" + inbound_rule = [ + { + 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"] + }, + ] +} + +resource "digitalocean_firewall" "ssh" { + name = "ssh-inbound" + inbound_rule = [ + { + protocol = "tcp" + port_range = "22" + source_addresses = ["0.0.0.0/0", "::/0"] + }, + { + protocol = "tcp" + port_range = "222" + source_addresses = ["0.0.0.0/0", "::/0"] + }, + { + protocol = "tcp" + port_range = "24" + source_addresses = ["0.0.0.0/0", "::/0"] + }, + + ] +} diff --git a/digitalocean/networking.tf b/digitalocean/networking.tf new file mode 100644 index 0000000..fcefd33 --- /dev/null +++ b/digitalocean/networking.tf @@ -0,0 +1,4 @@ +resource "digitalocean_floating_ip" "sydney" { + droplet_id = "${digitalocean_droplet.sydney.id}" + region = "${digitalocean_droplet.sydney.region}" +} diff --git a/main.tf b/main.tf index da7a452..633924b 100644 --- a/main.tf +++ b/main.tf @@ -49,3 +49,7 @@ module "monitoring" { gf-security-admin-password = "${var.gf-security-admin-password}" domain = "bb8.fun" } + +module "digitalocean" { + source = "digitalocean" +} diff --git a/providers.tf b/providers.tf index 681734e..428bd6d 100644 --- a/providers.tf +++ b/providers.tf @@ -13,3 +13,7 @@ provider "mysql" { username = "root" password = "${var.mysql_root_password}" } + +provider digitalocean { + token = "${var.digitalocean-token}" +} diff --git a/variables.tf b/variables.tf index 996621f..e70b152 100644 --- a/variables.tf +++ b/variables.tf @@ -44,3 +44,4 @@ variable "gf-security-admin-password" { variable "gitea-secret-key" {} variable "gitea-internal-token" {} variable "gitea-smtp-password" {} +variable "digitalocean-token" {}