aboutsummaryrefslogtreecommitdiff
path: root/flake/terraform.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2025-08-31 13:33:54 -0700
committerFranck Cuny <franck@fcuny.net>2025-08-31 13:33:54 -0700
commit145e1dab68caf3f57c53820c6359bef83a5ce52a (patch)
tree592546ad50121b32f386f532e3be8f75cb521d54 /flake/terraform.nix
parentadd terranix (diff)
downloadinfra-145e1dab68caf3f57c53820c6359bef83a5ce52a.tar.gz
manage terraform configuration with terranix
All the terraform configuration is managed within one state instead of having multiple state for each components. This might not be the best practice but it simplifies things for me. Now, all I need to do is to run `nix run .#tf -- plan` and I can see what will be changed for all the resources that I care about.
Diffstat (limited to '')
-rw-r--r--flake/terraform.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/flake/terraform.nix b/flake/terraform.nix
new file mode 100644
index 0000000..23cc6d3
--- /dev/null
+++ b/flake/terraform.nix
@@ -0,0 +1,40 @@
+{ lib, ... }:
+{
+ perSystem =
+ { pkgs, ... }:
+ let
+ mkTfWrapper =
+ {
+ tfPlugins,
+ cfg,
+ }:
+ let
+ pkg = pkgs.opentofu.withPlugins tfPlugins;
+ in
+ {
+ type = "app";
+ program = toString (
+ pkgs.writers.writeBash "tf" ''
+ set -xeuo pipefail
+ ln -snf ${cfg} config.tf.json
+ exec ${lib.getExe pkg} "$@"
+ ''
+ );
+ };
+ in
+ {
+ apps = {
+ tf = mkTfWrapper {
+ cfg = pkgs.adminTerraformCfg;
+ tfPlugins = p: [
+ p.cloudflare
+ p.digitalocean
+ p.external
+ p.google
+ p.null
+ p.random
+ ];
+ };
+ };
+ };
+}