Add the ability to cron for IP config and push that out with terraform

This commit is contained in:
Alexander Hosking 2017-09-17 23:38:39 -04:00
parent 0169c5a011
commit 39e4dca4a8
6 changed files with 112 additions and 15 deletions

View File

@ -33,11 +33,19 @@ resource "aws_route53_record" "wildcard_automatedbytes" {
resource "aws_route53_record" "support_automatedbytes" { resource "aws_route53_record" "support_automatedbytes" {
zone_id = "${aws_route53_zone.automatedbytes.zone_id}" zone_id = "${aws_route53_zone.automatedbytes.zone_id}"
name = "support.automatedbytes.com" name = "support.automatedbytes.com"
type = "CNAME" type = "A"
ttl = "5" ttl = "5"
records = ["${var.home_ip}"] 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 ## Email MX records
resource "aws_route53_record" "mx_automatedbytes" { resource "aws_route53_record" "mx_automatedbytes" {
zone_id = "${aws_route53_zone.automatedbytes.zone_id}" zone_id = "${aws_route53_zone.automatedbytes.zone_id}"

View File

@ -0,0 +1,3 @@
#!/bin/bash
IP=`curl ifconfig.co`
echo 'home_ip = "'$IP'"' > var_homeip.tfvar

View File

@ -1,7 +1,7 @@
{ {
"version": 3, "version": 3,
"terraform_version": "0.9.8", "terraform_version": "0.10.5",
"serial": 16, "serial": 21,
"lineage": "db7d87ff-3078-47ed-a0a9-91749a2dbba5", "lineage": "db7d87ff-3078-47ed-a0a9-91749a2dbba5",
"modules": [ "modules": [
{ {
@ -389,7 +389,7 @@
"id": "Z2HTSYFXB5HXD9_baby.ahoskingit.com_A", "id": "Z2HTSYFXB5HXD9_baby.ahoskingit.com_A",
"name": "baby.ahoskingit.com", "name": "baby.ahoskingit.com",
"records.#": "1", "records.#": "1",
"records.2764920476": "174.114.190.249", "records.3606820868": "173.34.159.142",
"set_identifier": "", "set_identifier": "",
"ttl": "5", "ttl": "5",
"type": "A", "type": "A",
@ -640,7 +640,7 @@
"id": "Z2HTSYFXB5HXD9_home.ahoskingit.com_A", "id": "Z2HTSYFXB5HXD9_home.ahoskingit.com_A",
"name": "home.ahoskingit.com", "name": "home.ahoskingit.com",
"records.#": "1", "records.#": "1",
"records.2764920476": "174.114.190.249", "records.3606820868": "173.34.159.142",
"set_identifier": "", "set_identifier": "",
"ttl": "5", "ttl": "5",
"type": "A", "type": "A",
@ -667,7 +667,7 @@
"id": "Z1K67K6B7LVE6O_home.ahoskingit.ca_A", "id": "Z1K67K6B7LVE6O_home.ahoskingit.ca_A",
"name": "home.ahoskingit.ca", "name": "home.ahoskingit.ca",
"records.#": "1", "records.#": "1",
"records.2764920476": "174.114.190.249", "records.3606820868": "173.34.159.142",
"set_identifier": "", "set_identifier": "",
"ttl": "5", "ttl": "5",
"type": "A", "type": "A",
@ -764,6 +764,33 @@
"deposed": [], "deposed": [],
"provider": "" "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": { "aws_route53_record.lab_ahoskingit": {
"type": "aws_route53_record", "type": "aws_route53_record",
"depends_on": [ "depends_on": [
@ -1025,17 +1052,17 @@
"aws_route53_zone.automatedbytes" "aws_route53_zone.automatedbytes"
], ],
"primary": { "primary": {
"id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A",
"attributes": { "attributes": {
"fqdn": "support.automatedbytes.com", "fqdn": "support.automatedbytes.com",
"health_check_id": "", "health_check_id": "",
"id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A",
"name": "support.automatedbytes.com", "name": "support.automatedbytes.com",
"records.#": "1", "records.#": "1",
"records.2764920476": "174.114.190.249", "records.3606820868": "173.34.159.142",
"set_identifier": "", "set_identifier": "",
"ttl": "5", "ttl": "5",
"type": "CNAME", "type": "A",
"zone_id": "Z1H1ULBVLBNLL2" "zone_id": "Z1H1ULBVLBNLL2"
}, },
"meta": { "meta": {

66
ahoskingit/terraform/terraform.tfstate.backup Normal file → Executable file
View File

@ -1,7 +1,7 @@
{ {
"version": 3, "version": 3,
"terraform_version": "0.9.8", "terraform_version": "0.9.8",
"serial": 15, "serial": 21,
"lineage": "db7d87ff-3078-47ed-a0a9-91749a2dbba5", "lineage": "db7d87ff-3078-47ed-a0a9-91749a2dbba5",
"modules": [ "modules": [
{ {
@ -764,6 +764,33 @@
"deposed": [], "deposed": [],
"provider": "" "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": { "aws_route53_record.lab_ahoskingit": {
"type": "aws_route53_record", "type": "aws_route53_record",
"depends_on": [ "depends_on": [
@ -792,6 +819,37 @@
"deposed": [], "deposed": [],
"provider": "" "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": { "aws_route53_record.ns1_ahoskingit": {
"type": "aws_route53_record", "type": "aws_route53_record",
"depends_on": [ "depends_on": [
@ -994,17 +1052,17 @@
"aws_route53_zone.automatedbytes" "aws_route53_zone.automatedbytes"
], ],
"primary": { "primary": {
"id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A",
"attributes": { "attributes": {
"fqdn": "support.automatedbytes.com", "fqdn": "support.automatedbytes.com",
"health_check_id": "", "health_check_id": "",
"id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_CNAME", "id": "Z1H1ULBVLBNLL2_support.automatedbytes.com_A",
"name": "support.automatedbytes.com", "name": "support.automatedbytes.com",
"records.#": "1", "records.#": "1",
"records.2764920476": "174.114.190.249", "records.2764920476": "174.114.190.249",
"set_identifier": "", "set_identifier": "",
"ttl": "5", "ttl": "5",
"type": "CNAME", "type": "A",
"zone_id": "Z1H1ULBVLBNLL2" "zone_id": "Z1H1ULBVLBNLL2"
}, },
"meta": { "meta": {

2
ahoskingit/terraform/terrarist.py Normal file → Executable file
View File

@ -27,7 +27,7 @@ if __name__ == "__main__":
vault = Vault(password) vault = Vault(password)
data = vault.load(open(args.vault_file).read()) 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(): for key, value in data.items():
cmd.append("--var") cmd.append("--var")

View File

@ -0,0 +1 @@
home_ip = "173.34.159.142"