From 39e4dca4a81890c6ddcd0e8a992ef54871f7b53b Mon Sep 17 00:00:00 2001 From: Alexander Hosking Date: Sun, 17 Sep 2017 23:38:39 -0400 Subject: [PATCH] Add the ability to cron for IP config and push that out with terraform --- ahoskingit/terraform/dns_automatedbytes.tf | 10 ++- ahoskingit/terraform/get_current_ip.sh | 3 + ahoskingit/terraform/terraform.tfstate | 45 ++++++++++--- ahoskingit/terraform/terraform.tfstate.backup | 66 +++++++++++++++++-- ahoskingit/terraform/terrarist.py | 2 +- ahoskingit/terraform/var_homeip.tfvar | 1 + 6 files changed, 112 insertions(+), 15 deletions(-) create mode 100755 ahoskingit/terraform/get_current_ip.sh mode change 100644 => 100755 ahoskingit/terraform/terraform.tfstate.backup mode change 100644 => 100755 ahoskingit/terraform/terrarist.py create mode 100644 ahoskingit/terraform/var_homeip.tfvar diff --git a/ahoskingit/terraform/dns_automatedbytes.tf b/ahoskingit/terraform/dns_automatedbytes.tf index 5c4cfd0..f243a1a 100644 --- a/ahoskingit/terraform/dns_automatedbytes.tf +++ b/ahoskingit/terraform/dns_automatedbytes.tf @@ -33,11 +33,19 @@ resource "aws_route53_record" "wildcard_automatedbytes" { resource "aws_route53_record" "support_automatedbytes" { zone_id = "${aws_route53_zone.automatedbytes.zone_id}" name = "support.automatedbytes.com" - type = "CNAME" + type = "A" ttl = "5" records = ["${var.home_ip}"] } +resource "aws_route53_record" "kfa_support_automatedbytes" { + zone_id = "${aws_route53_zone.automatedbytes.zone_id}" + name = "kfa.support.automatedbytes.com" + type = "CNAME" + ttl = "5" + records = ["support.automatedbytes.com"] +} + ## Email MX records resource "aws_route53_record" "mx_automatedbytes" { zone_id = "${aws_route53_zone.automatedbytes.zone_id}" diff --git a/ahoskingit/terraform/get_current_ip.sh b/ahoskingit/terraform/get_current_ip.sh new file mode 100755 index 0000000..64f0559 --- /dev/null +++ b/ahoskingit/terraform/get_current_ip.sh @@ -0,0 +1,3 @@ +#!/bin/bash +IP=`curl ifconfig.co` +echo 'home_ip = "'$IP'"' > var_homeip.tfvar diff --git a/ahoskingit/terraform/terraform.tfstate b/ahoskingit/terraform/terraform.tfstate index c9e8453..ed8f5fd 100644 --- a/ahoskingit/terraform/terraform.tfstate +++ b/ahoskingit/terraform/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 3, - "terraform_version": "0.9.8", - "serial": 16, + "terraform_version": "0.10.5", + "serial": 21, "lineage": "db7d87ff-3078-47ed-a0a9-91749a2dbba5", "modules": [ { @@ -389,7 +389,7 @@ "id": "Z2HTSYFXB5HXD9_baby.ahoskingit.com_A", "name": "baby.ahoskingit.com", "records.#": "1", - "records.2764920476": "174.114.190.249", + "records.3606820868": "173.34.159.142", "set_identifier": "", "ttl": "5", "type": "A", @@ -640,7 +640,7 @@ "id": "Z2HTSYFXB5HXD9_home.ahoskingit.com_A", "name": "home.ahoskingit.com", "records.#": "1", - "records.2764920476": "174.114.190.249", + "records.3606820868": "173.34.159.142", "set_identifier": "", "ttl": "5", "type": "A", @@ -667,7 +667,7 @@ "id": "Z1K67K6B7LVE6O_home.ahoskingit.ca_A", "name": "home.ahoskingit.ca", "records.#": "1", - "records.2764920476": "174.114.190.249", + "records.3606820868": "173.34.159.142", "set_identifier": "", "ttl": "5", "type": "A", @@ -764,6 +764,33 @@ "deposed": [], "provider": "" }, + "aws_route53_record.kfa_support_automatedbytes": { + "type": "aws_route53_record", + "depends_on": [ + "aws_route53_zone.automatedbytes" + ], + "primary": { + "id": "Z1H1ULBVLBNLL2_kfa.support.automatedbytes.com_CNAME", + "attributes": { + "fqdn": "kfa.support.automatedbytes.com", + "health_check_id": "", + "id": "Z1H1ULBVLBNLL2_kfa.support.automatedbytes.com_CNAME", + "name": "kfa.support.automatedbytes.com", + "records.#": "1", + "records.645133509": "support.automatedbytes.com", + "set_identifier": "", + "ttl": "5", + "type": "CNAME", + "zone_id": "Z1H1ULBVLBNLL2" + }, + "meta": { + "schema_version": "2" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, "aws_route53_record.lab_ahoskingit": { "type": "aws_route53_record", "depends_on": [ @@ -1025,17 +1052,17 @@ "aws_route53_zone.automatedbytes" ], "primary": { - "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", + "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A", "attributes": { "fqdn": "support.automatedbytes.com", "health_check_id": "", - "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", + "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A", "name": "support.automatedbytes.com", "records.#": "1", - "records.2764920476": "174.114.190.249", + "records.3606820868": "173.34.159.142", "set_identifier": "", "ttl": "5", - "type": "CNAME", + "type": "A", "zone_id": "Z1H1ULBVLBNLL2" }, "meta": { diff --git a/ahoskingit/terraform/terraform.tfstate.backup b/ahoskingit/terraform/terraform.tfstate.backup old mode 100644 new mode 100755 index ecc4557..998ebb8 --- a/ahoskingit/terraform/terraform.tfstate.backup +++ b/ahoskingit/terraform/terraform.tfstate.backup @@ -1,7 +1,7 @@ { "version": 3, "terraform_version": "0.9.8", - "serial": 15, + "serial": 21, "lineage": "db7d87ff-3078-47ed-a0a9-91749a2dbba5", "modules": [ { @@ -764,6 +764,33 @@ "deposed": [], "provider": "" }, + "aws_route53_record.kfa_support_automatedbytes": { + "type": "aws_route53_record", + "depends_on": [ + "aws_route53_zone.automatedbytes" + ], + "primary": { + "id": "Z1H1ULBVLBNLL2_kfa.support.automatedbytes.com_CNAME", + "attributes": { + "fqdn": "kfa.support.automatedbytes.com", + "health_check_id": "", + "id": "Z1H1ULBVLBNLL2_kfa.support.automatedbytes.com_CNAME", + "name": "kfa.support.automatedbytes.com", + "records.#": "1", + "records.645133509": "support.automatedbytes.com", + "set_identifier": "", + "ttl": "5", + "type": "CNAME", + "zone_id": "Z1H1ULBVLBNLL2" + }, + "meta": { + "schema_version": "2" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, "aws_route53_record.lab_ahoskingit": { "type": "aws_route53_record", "depends_on": [ @@ -792,6 +819,37 @@ "deposed": [], "provider": "" }, + "aws_route53_record.mx_automatedbytes": { + "type": "aws_route53_record", + "depends_on": [ + "aws_route53_zone.automatedbytes" + ], + "primary": { + "id": "Z1H1ULBVLBNLL2_automatedbytes.com_MX", + "attributes": { + "fqdn": "automatedbytes.com", + "health_check_id": "", + "id": "Z1H1ULBVLBNLL2_automatedbytes.com_MX", + "name": "automatedbytes.com", + "records.#": "5", + "records.2553098020": "5 ALT2.ASPMX.L.GOOGLE.COM", + "records.299078338": "1 ASPMX.L.GOOGLE.COM", + "records.3330381287": "10 ALT4.ASPMX.L.GOOGLE.COM", + "records.667235188": "10 ALT3.ASPMX.L.GOOGLE.COM", + "records.931422958": "5 ALT1.ASPMX.L.GOOGLE.COM", + "set_identifier": "", + "ttl": "60", + "type": "MX", + "zone_id": "Z1H1ULBVLBNLL2" + }, + "meta": { + "schema_version": "2" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, "aws_route53_record.ns1_ahoskingit": { "type": "aws_route53_record", "depends_on": [ @@ -994,17 +1052,17 @@ "aws_route53_zone.automatedbytes" ], "primary": { - "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", + "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A", "attributes": { "fqdn": "support.automatedbytes.com", "health_check_id": "", - "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", + "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A", "name": "support.automatedbytes.com", "records.#": "1", "records.2764920476": "174.114.190.249", "set_identifier": "", "ttl": "5", - "type": "CNAME", + "type": "A", "zone_id": "Z1H1ULBVLBNLL2" }, "meta": { diff --git a/ahoskingit/terraform/terrarist.py b/ahoskingit/terraform/terrarist.py old mode 100644 new mode 100755 index e8d61fe..dde44c4 --- a/ahoskingit/terraform/terrarist.py +++ b/ahoskingit/terraform/terrarist.py @@ -27,7 +27,7 @@ if __name__ == "__main__": vault = Vault(password) data = vault.load(open(args.vault_file).read()) - cmd = ["terraform", args.action, "--var", "environment=%s" %args.environment ] + cmd = ["terraform", args.action, "--var", "environment=%s" %args.environment, '--var-file=var_homeip.tfvar' ] for key, value in data.items(): cmd.append("--var") diff --git a/ahoskingit/terraform/var_homeip.tfvar b/ahoskingit/terraform/var_homeip.tfvar new file mode 100644 index 0000000..30064a7 --- /dev/null +++ b/ahoskingit/terraform/var_homeip.tfvar @@ -0,0 +1 @@ +home_ip = "173.34.159.142"