summaryrefslogtreecommitdiff
path: root/ext/terranix/cloudflare/pages_domains.nix
blob: c3c45bbdba2cabde1502d17db71168f979a559eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{lib, ...}: let
  setDomainsFor = {
    account_id,
    project,
    domains,
  }:
    lib.listToAttrs (
      map (domain: {
        name = "${project}_${builtins.replaceStrings ["."] ["_"] domain}";
        value = {
          inherit account_id;
          project_name = lib.tfRef "resource.cloudflare_pages_project.${project}.name";
          inherit domain;
        };
      })
      domains
    );
in {
  resource.cloudflare_pages_domain =
    setDomainsFor {
      account_id = lib.tfRef "var.account_id";
      project = "personal_website";
      domains = ["getchoo.com"];
    }
    // setDomainsFor {
      account_id = lib.tfRef "var.account_id";
      project = "teawie_api";
      domains = ["api.getchoo.com"];
    };
}