Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google DNS provider #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.terraform/
terraform.tfstate*
.terraform.tfstate*
terraform.tfvars
57 changes: 57 additions & 0 deletions dns/google/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
variable "count" {}

variable "project" {}

variable "region" {}

variable "creds_file" {}

variable "managed_zone" {}

variable "domain" {}

variable "hostnames" {
type = "list"
}

variable "public_ips" {
type = "list"
}

provider "google" {
credentials = "${file(var.creds_file)}"
project = "${var.project}"
region = "${var.region}"
}

resource "google_dns_record_set" "hosts" {
count = "${var.count}"

name = "${element(var.hostnames, count.index)}.${var.domain}."
type = "A"
ttl = 300
managed_zone = "${var.managed_zone}"
rrdatas = ["${element(var.public_ips, count.index)}"]
}

resource "google_dns_record_set" "domain" {
name = "${var.domain}."
type = "A"
ttl = 300
managed_zone = "${var.managed_zone}"
rrdatas = ["${element(var.public_ips, 0)}"]
}

resource "google_dns_record_set" "wildcard" {
depends_on = ["google_dns_record_set.domain"]

name = "*.${var.domain}."
type = "CNAME"
ttl = 300
managed_zone = "${var.managed_zone}"
rrdatas = ["${var.domain}."]
}

output "domains" {
value = ["${google_dns_record_set.hosts.*.name}"]
}
15 changes: 15 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ module "dns" {
hostnames = "${module.provider.hostnames}"
}

/*
module "dns" {
source = "./dns/google"

count = "${var.hosts}"
project = "${var.google_project}"
region = "${var.google_region}"
creds_file = "${var.google_credentials_file}"
managed_zone = "${var.google_managed_zone}"
domain = "${var.domain}"
public_ips = "${module.provider.public_ips}"
hostnames = "${module.provider.hostnames}"
}
*/

module "swap" {
source = "./service/swap"

Expand Down
19 changes: 18 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,28 @@ variable "digitalocean_region" {
default = "nyc1"
}

/* dns */
/* cloudflare */
variable "cloudflare_email" {
default = ""
}

variable "cloudflare_token" {
default = ""
}

/* google dns */
variable "google_project" {
default = ""
}

variable "google_region" {
default = ""
}

variable "google_managed_zone" {
default = ""
}

variable "google_credentials_file" {
default = ""
}