feat(proxy): use route53 for smart proxy dns

This commit is contained in:
Iain Learmonth 2023-03-26 14:45:55 +01:00
parent d6e44cdc0a
commit aec4c48842
2 changed files with 3 additions and 37 deletions

View file

@ -116,7 +116,7 @@ class ProxyAutomation(TerraformAutomation):
{% for origin in origins %}
server {
listen 443 ssl;
server_name origin-{{ origin.id }}.{{ provider }}.smart.{{ smart_zone[:-1] }};
server_name origin-{{ origin.id }}.{{ smart_zone[:-1] }};
location / {
proxy_set_header Accept-Encoding "";
proxy_ssl_server_name on;

View file

@ -33,9 +33,6 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
aws = {
version = "~> 4.41.0"
}
dns = {
version = "~> 3.2.3"
}
}
}
@ -49,21 +46,7 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
region = "us-east-2"
}
provider "dns" {
update {
server = local.rfc2136_nameserver
key_name = local.rfc2136_tsig_key
key_secret = local.rfc2136_tsig_secret
key_algorithm = "hmac-sha512"
timeout = "60s"
retries = 5
}
}
locals {
rfc2136_nameserver = "{{ rfc2136_nameserver }}"
rfc2136_tsig_key = "{{ rfc2136_tsig_key }}"
rfc2136_tsig_secret = "{{ rfc2136_tsig_secret }}"
smart_zone = "{{ smart_zone }}"
}
@ -98,28 +81,11 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
source = "{{ terraform_modules_path }}/terraform-aws-bc-smart-proxy-instance"
context = module.label_{{ group.id }}.context
name = "smart-proxy"
config_filename = "smart_proxy.{{ group.id }}.conf"
disable_api_termination = false
domain_name = "cloudfront.smart.${local.smart_zone}"
rfc2136_nameserver = local.rfc2136_nameserver
rfc2136_tsig_key = local.rfc2136_tsig_key
rfc2136_tsig_secret = local.rfc2136_tsig_secret
dns_zone = "{{ smart_aws_zone }}"
max_transfer_per_hour = "10000000000"
}
resource "aws_s3_object" "smart_config_{{ group.id }}" {
bucket = module.smart_proxy_{{ group.id }}.config_bucket_name
key = "default"
source = "smart_proxy.{{ group.id }}.conf"
etag = filemd5("smart_proxy.{{ group.id }}.conf")
}
{% endif %}
resource "dns_a_record_set" "smart_dns_{{ origin.id }}" {
zone = "{{ smart_zone }}"
name = "origin-{{ origin.id }}.cloudfront.smart"
addresses = module.smart_proxy_{{ origin.group.id }}.ip_addresses
ttl = 60
}
{% endfor %}
{% endfor %}