Skip to content

Instantly share code, notes, and snippets.

@danielcompton
Created December 12, 2017 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielcompton/daf8ec1a77d3640af2fc5bb9c40d84c2 to your computer and use it in GitHub Desktop.
Save danielcompton/daf8ec1a77d3640af2fc5bb9c40d84c2 to your computer and use it in GitHub Desktop.
GCP and DNSimple dual DNS records with Terraform
module "deps_dns_app_v6" {
source = "../modules/dns_record"
name = "app"
type = "AAAA"
value = "${google_compute_global_address.deps-ipv6.address}"
}
module "deps_return_path" {
source = "../modules/dns_record"
name = "return-path"
type = "CNAME"
ttl = 3600
value = "pm.mtasv.net"
}
# Note this only works for CNAMEs and A/AAAA records.
variable "domain" {
default = "deps.co"
}
variable "name" {}
variable "type" {}
variable "value" {}
variable "ttl" {
default = 300
}
variable "shared_project" {
default = "my-shared-project"
}
variable "managed_zone" {
default = "my-managed-zone"
}
resource "google_dns_record_set" "record" {
name = "${var.name}.${var.domain}."
type = "${var.type}"
ttl = "${var.ttl}"
managed_zone = "${var.managed_zone}"
project = "${var.shared_project}"
rrdatas = ["${var.type == "CNAME" ? "${var.value}." : var.value}"]
}
resource "dnsimple_record" "record" {
domain = "${var.domain}"
name = "${var.name}"
type = "${var.type}"
ttl = "${var.ttl}"
value = "${var.value}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment