From 255538c32e10e5dac29cac39a28ce499227f067f Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Tue, 4 Oct 2022 17:50:11 -0700 Subject: ops(terraform): individual actions for init/plan/apply Don't do all of these actions together, instead provide helpers for both init, plan, and apply. --- ops/default.nix | 1 + ops/gcp-backups/default.nix | 14 +++++++++++--- ops/github/README.org | 4 ++-- ops/github/default.nix | 29 +++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 ops/github/default.nix (limited to 'ops') diff --git a/ops/default.nix b/ops/default.nix index ec2bc02..194252c 100644 --- a/ops/default.nix +++ b/ops/default.nix @@ -3,4 +3,5 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: { buildkite = pkgs.callPackage ./buildkite { }; gcp-backups = pkgs.callPackage ./gcp-backups { }; + github = pkgs.callPackage ./github { }; }) diff --git a/ops/gcp-backups/default.nix b/ops/gcp-backups/default.nix index 44252e2..0e9ed07 100644 --- a/ops/gcp-backups/default.nix +++ b/ops/gcp-backups/default.nix @@ -8,13 +8,21 @@ pkgs.stdenv.mkDerivation rec { name = "tf-gcp-backups"; src = ./.; - setup = pkgs.writeShellScriptBin "tf-gcp-backups-setup" '' + init = pkgs.writeShellScriptBin "tf-gcp-backups-init" '' set -ueo pipefail - cd $(git rev-parse --show-toplevel)/ops/gcp-backups - ${terraform}/bin/terraform init + ''; + + plan = pkgs.writeShellScriptBin "tf-gcp-backups-plan" '' + set -ueo pipefail + cd $(git rev-parse --show-toplevel)/ops/gcp-backups ${terraform}/bin/terraform plan + ''; + + apply = pkgs.writeShellScriptBin "tf-gcp-backups-apply" '' + set -ueo pipefail + cd $(git rev-parse --show-toplevel)/ops/gcp-backups ${terraform}/bin/terraform apply ''; } diff --git a/ops/github/README.org b/ops/github/README.org index 86c664a..5906fbd 100644 --- a/ops/github/README.org +++ b/ops/github/README.org @@ -5,8 +5,8 @@ This terraform configuration is to manage my GitHub configuration (repositories, There's nothing special regarding how to use this repository. #+begin_src sh -GITHUB_TOKEN=(pass api/github/terraform) terraform plan -GITHUB_TOKEN=(pass api/github/terraform) terraform apply +GITHUB_TOKEN=(pass api/github/terraform) nix run .#ops.github.plan +GITHUB_TOKEN=(pass api/github/terraform) nix run .#ops.github.init #+end_src * Credentials diff --git a/ops/github/default.nix b/ops/github/default.nix new file mode 100644 index 0000000..a36aa12 --- /dev/null +++ b/ops/github/default.nix @@ -0,0 +1,29 @@ +{ pkgs }: +let + terraform = pkgs.terraform.withPlugins (p: [ + p.google + p.github + ]); +in +pkgs.stdenv.mkDerivation rec { + name = "tf-github"; + src = ./.; + + init = pkgs.writeShellScriptBin "tf-github-init" '' + set -ueo pipefail + cd $(git rev-parse --show-toplevel)/ops/github + ${terraform}/bin/terraform init + ''; + + plan = pkgs.writeShellScriptBin "tf-github-plan" '' + set -ueo pipefail + cd $(git rev-parse --show-toplevel)/ops/github + ${terraform}/bin/terraform plan + ''; + + apply = pkgs.writeShellScriptBin "tf-github-apply" '' + set -ueo pipefail + cd $(git rev-parse --show-toplevel)/ops/github + ${terraform}/bin/terraform apply + ''; +} -- cgit 1.4.1