Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
uses variables to templatize dns, ses resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Hashfyre committed Dec 21, 2019
1 parent 364f55b commit debd8bd
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 54 deletions.
90 changes: 39 additions & 51 deletions terraform/dns.tf
Original file line number Diff line number Diff line change
@@ -1,144 +1,132 @@
resource "aws_route53_zone" "speakforme-in" {
name = "speakforme.in"
resource "aws_route53_zone" "campaign-domain" {
name = "${var.campaign-domain}"

tags {
Environment = "production"
tags = {
Environment = "${var.campaign-env}"
terraform = true
}
}

resource "aws_route53_record" "campaign-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
name = "campaign.speakforme.in"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "${var.campaign-a-domain}"
type = "A"
ttl = "300"
records = ["34.199.252.2"]
}

locals {
postal-server-ip = "18.211.250.184"
records = "${var.campaign-a-ip}"
}

resource "aws_route53_record" "postal-mx-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "mx.postal"
type = "A"
ttl = "300"
records = ["${local.postal-server-ip}"]
records = "${var.postal-server-ip}"
}

resource "aws_route53_record" "postal-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "postal"
type = "A"
ttl = "300"
records = ["${local.postal-server-ip}"]
records = "${var.postal-server-ip}"
}

resource "aws_route53_record" "postal-rp-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "rp.postal"
type = "A"
ttl = "300"
records = ["${local.postal-server-ip}"]
records = "${var.postal-server-ip}"
}

resource "aws_route53_record" "postal-sf-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "sf.postal"
type = "A"
ttl = "300"
records = ["${local.postal-server-ip}"]
records = "${var.postal-server-ip}"
}

resource "aws_route53_record" "storage-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "storage"
type = "A"
ttl = "300"
records = ["35.153.240.239"]
records = "${var.storage-a-ip}"
}

resource "aws_route53_record" "speakforme-a" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "speakforme.in"
type = "A"
ttl = "300"
records = ["104.198.14.52"]
records = "${var.speakforme-a-ip}"
}

// CNAME Records

resource "aws_route53_record" "beta-cname" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "beta"
type = "CNAME"
ttl = "1800"
records = ["speakforme.github.io."]
records = "${var.beta-cname}"
}

resource "aws_route53_record" "netlify-cname" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "netlify"
type = "CNAME"
ttl = "1800"
records = ["speakforme.netlify.com."]
records = "${var.netlify-cname}"
}

resource "aws_route53_record" "psrp-email-cname" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "psrp.email"
type = "CNAME"
ttl = "1800"
records = ["rp.postal.speakforme.in."]
records = "${var.psrp-email-cname}"
}

resource "aws_route53_record" "psrp-cname" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "psrp"
type = "CNAME"
ttl = "1800"
records = ["rp.postal.speakforme.in."]
records = "${var.psrp-cname}"
}

resource "aws_route53_record" "www" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "www"
type = "CNAME"
ttl = "1800"
records = ["speakforme.netlify.com."]
records = "${var.www-cname}"
}

// MX Records
resource "aws_route53_record" "email-mx" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
name = "email"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "${var.email-mx-name}"
type = "MX"
ttl = "60"

records = [
"10 inbound-smtp.eu-west-1.amazonaws.com.",
]
records = "${var.email-mx-record}"
}

resource "aws_route53_record" "routes-mx" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
name = "routes"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "${var.routes-mx-name}"
type = "MX"
ttl = "1800"

records = [
"10 mx.postal.speakforme.in.",
]
records = "${var.routes-mx-record}"
}


resource "aws_route53_record" "speakforme-mx" {
zone_id = "${aws_route53_zone.speakforme-in.id}"
name = "speakforme.in"
zone_id = "${aws_route53_zone.campaign-domain.id}"
name = "${var.speakforme-mx-name}"
type = "MX"
ttl = "1800"

records = [
"10 mx.postal.speakforme.in.",
]
records = "${var.speakforme-mx-record}"
}
6 changes: 3 additions & 3 deletions terraform/ses.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ resource "aws_ses_receipt_rule" "store-and-acknowledge" {
// Emails must be bcc'd to this email address
recipients = [
// This supports bcc+(campaign-target-code) as well
"bcc@email.speakforme.in",
"bcc@${var.email-mx-name}.${var.campaign-domain}",

// This is just so that we can verify this in SES as a sending email address
"info@email.speakforme.in",
"info@${var.email-mx-name}.${var.campaign-domain}",
]

// We don't need no AV scans
scan_enabled = false

// Store Then Process
s3_action {
bucket_name = "speakforme-emails"
bucket_name = "${var.email-bucket}"
position = 1
}

Expand Down
91 changes: 91 additions & 0 deletions terraform/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
variable "campaign-a-ip" {
type = "list"
default = ["34.199.252.2"]
}

variable "campaign-domain" {
default = "speakforme.in"
}

variable "campaign-env" {
default = "production"
}

variable "campaign-a-domain" {
default = "campaign.speakforme.in"
}

variable "postal-server-ip" {
type = "list"
default = ["18.211.250.184"]
}

variable "storage-a-ip" {
type = "list"
default = ["35.153.240.239"]
}

variable "speakforme-a-ip" {
type = "list"
default = ["104.198.14.52"]
}

variable "beta-cname" {
type = "list"
default = ["speakforme.github.io."]
}

variable "netlify-cname" {
type = "list"
default = ["speakforme.netlify.com."]
}

variable "psrp-email-cname" {
type = "list"
default = ["rp.postal.speakforme.in."]
}

variable "psrp-cname" {
type = "list"
default = ["rp.postal.speakforme.in."]
}

variable "www-cname" {
type = "list"
default = ["speakforme.netlify.com."]
}

variable "email-mx-record" {
type = "list"
default = ["10 inbound-smtp.eu-west-1.amazonaws.com."]
}

variable "email-mx-name" {
default = "email"
}

variable "routes-mx-record" {
type = "list"
default = ["10 mx.postal.speakforme.in."]
}

variable "routes-mx-name" {
default = "routes"
}

variable "speakforme-mx-name" {
default = "speakforme.in"
}

variable "speakforme-mx-record" {
type = "list"
default = ["10 mx.postal.speakforme.in."]
}

variable "infrastructure-bucket" {
default = "speakforme-infrastructure"
}

variable "email-bucket" {
default = "speakforme-emails"
}

0 comments on commit debd8bd

Please sign in to comment.