From f605dd332d51590f0ade93345f3cd048661c0666 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 8 Jun 2019 17:00:32 -0300 Subject: Use terraform-godaddy and Terraform 0.11 The =terraform-godaddy= package supports only Terraform 0.11 as of now. It is not packaged by default by nixpkgs, and the =postInstall= hook is required because Terraform looks for providers usinthe the =terraform-provider-$name= template, which the package doesn't follow. I had to remove the loop on vps.tf since it requires Terraform 0.12. I'll either wait for =terraform-godaddy= to upgrade to 0.12 or try to do it myself if it bothers me enough. --- TODOs.org | 1 + default.nix | 19 +++++++++++++++++-- secrets/envrc.sh | Bin 1709 -> 1801 bytes vps.tf | 22 ++++++++++++++-------- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/TODOs.org b/TODOs.org index af2e8c2..65a0975 100644 --- a/TODOs.org +++ b/TODOs.org @@ -236,6 +236,7 @@ This was I can compartimentalize the data storage to easily backup and duplicate * Nice to have ** =euandreh.org= as =$tld= ** Nix Terraform provisioning +** Upgrade =terraform-godaddy= to 0.12 to support looping over CNAME records ** Upgrade =docker-compose.yaml= file from version 2 to version 3 ** Full blue/green deployments without downtime Only when doing a voluntary restore from backup in a newly created volume. diff --git a/default.nix b/default.nix index 464e878..90cdb4e 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,19 @@ -let pkgs = import { }; +let + pkgs = import { }; + terraform-godaddy = pkgs.buildGoModule rec { + name = "terraform-godaddy-${version}"; + version = "1.6.4"; + src = pkgs.fetchFromGitHub { + owner = "n3integration"; + repo = "terraform-godaddy"; + rev = "v${version}"; + sha256 = "00blqsan74s53dk9ab4hxi1kzxi46k57dr65dmbiradfa3yz3852"; + }; + modSha256 = "10n2dy7q9kk1ly58sw965n6qa8l0nffh8vyd1vslx0gdlyj25xxs"; + postInstall = "mv $out/bin/terraform-godaddy $out/bin/terraform-provider-godaddy"; + }; in rec { + terraform-godaddy2 = terraform-godaddy; utils = import ./utils.nix { pkgs = pkgs; src = pkgs.nix-gitignore.gitignoreSource [ ] ./.; @@ -39,7 +53,8 @@ in rec { git-crypt gettext terraform-providers.digitalocean - terraform_0_12 + terraform-godaddy + terraform-full ansible ]; buildPhase = '' diff --git a/secrets/envrc.sh b/secrets/envrc.sh index 3251d7d..b82402f 100644 Binary files a/secrets/envrc.sh and b/secrets/envrc.sh differ diff --git a/vps.tf b/vps.tf index 24c928f..b358f89 100644 --- a/vps.tf +++ b/vps.tf @@ -1,6 +1,10 @@ -variable "do_token" {} variable "floating_ip" {} +variable "do_token" {} +variable "tld" {} +variable "wallabag_tld" {} +variable "nextcloud_tld" {} + provider "digitalocean" { token = "${var.do_token}" version = "~> 1.1" @@ -67,13 +71,15 @@ resource "godaddy_domain_record" "vps_tld" { domain = "${var.tld}" addresses = ["${var.floating_ip}"] - dynamic "record" { - for_each = local.cname_subdomains + record { + type = "CNAME" + name = "${var.tld}" + data = "${var.wallabag_tld}" + } - content { - type = "CNAME" - name = tag - data = "${var.tld}" - } + record { + type = "CNAME" + name = "${var.tld}" + data = "${var.nextcloud_tld}" } } \ No newline at end of file -- cgit v1.2.3