Last active
January 22, 2019 12:14
-
-
Save panbanda/b5479f35792f9680a94a7fdea13a233c to your computer and use it in GitHub Desktop.
Setup a domain on CloudFlare + Google MX using Terraform
This file contains hidden or 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
variable "email" {} | |
variable "token" {} | |
variable "domain" {} | |
provider "cloudflare" { | |
email = "${var.email}" | |
token = "${var.token}" | |
} | |
# Setup the root domain | |
resource "cloudflare_record" "main" { | |
domain = "${var.domain}" | |
name = "@" | |
value = "192.168.0.11" | |
type = "A" | |
proxied = true | |
} | |
# Setup the www CNAME for your domain | |
resource "cloudflare_record" "main-www" { | |
domain = "${var.domain}" | |
name = "www" | |
value = "${var.domain}" | |
type = "CNAME" | |
proxied = true | |
} | |
# Setting up Google MX | |
resource "cloudflare_record" "google-mx-record-aspmx" { | |
domain = "${var.domain}" | |
name = "@" | |
value = "aspmx.l.google.com" | |
type = "MX" | |
priority = 1 | |
} | |
resource "cloudflare_record" "google-mx-record-alt1" { | |
domain = "${var.domain}" | |
name = "@" | |
value = "alt1.aspmx.l.google.com" | |
type = "MX" | |
priority = 5 | |
} | |
resource "cloudflare_record" "google-mx-record-alt2" { | |
domain = "${var.domain}" | |
name = "@" | |
value = "alt2.aspmx.l.google.com" | |
type = "MX" | |
priority = 5 | |
} | |
resource "cloudflare_record" "google-mx-record-alt3" { | |
domain = "${var.domain}" | |
name = "@" | |
value = "alt3.aspmx.l.google.com" | |
type = "MX" | |
priority = 10 | |
} | |
resource "cloudflare_record" "google-mx-record-alt4" { | |
domain = "${var.domain}" | |
name = "@" | |
value = "alt4.aspmx.l.google.com" | |
type = "MX" | |
priority = 10 | |
} |
This file contains hidden or 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
# email = cloudflare email address | |
# token = cloudflare api token from profile page | |
# domain = the domain you're wanting to update on cloudflare | |
terraform apply -var [email protected] -var token=111111111111111111111 -var domain=myawesomedomain.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Google MX interpolated using
count