diff --git a/ansible/vars/cloudflare_vars.yml b/ansible/vars/cloudflare_vars.yml deleted file mode 100755 index 94fd193..0000000 --- a/ansible/vars/cloudflare_vars.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -cloudflare_zone_ids: - "monitor.valiantlynx.com": - zone_id: "cc6721eb589ec5e29adc0a306fa5d5fe" - service: "grafana" - port: 3000 - "kuma.valiantlynx.com": - zone_id: "cc6721eb589ec5e29adc0a306fa5d5fe" - service: "uptime-kuma" - port: 3001 - \ No newline at end of file diff --git a/terraform/modules/ec2/main.tf b/terraform/modules/ec2/main.tf index 0640fb3..973d376 100644 --- a/terraform/modules/ec2/main.tf +++ b/terraform/modules/ec2/main.tf @@ -32,26 +32,27 @@ data "template_file" "cloudflare_vars" { template = <<-EOT --- cloudflare_zone_ids: - %{ for domain, details in var.cloudflare_zone_ids ~} - %{ if details.include_root ~} + %{ for domain, details in var.cloudflare_zone_ids ~} + %{ if details.include_root ~} "${domain}": zone_id: "${details.zone_id}" service: "${details.service}" port: ${details.port} - %{ endif ~} - %{ if details.include_subdomains ~} - %{ for subdomain in details.subdomains ~} - "${subdomain.name}.${domain}": - zone_id: "${details.zone_id}" - service: "${subdomain.service}" - port: ${subdomain.port} - %{ endfor ~} - %{ endif ~} - %{ endfor ~} + %{ endif ~} + %{ if details.include_subdomains ~} + %{ for subdomain in details.subdomains ~} + "${subdomain.name}.${domain}": + zone_id: "${details.zone_id}" + service: "${subdomain.service}" + port: ${subdomain.port} + %{ endfor ~} + %{ endif ~} + %{ endfor ~} EOT } + resource "local_file" "cloudflare_vars_file" { filename = "${abspath(path.module)}/../../../ansible/vars/cloudflare_vars.yml" content = data.template_file.cloudflare_vars.rendered