Go to file
Kiara Grouwstra 2c3a7ee24c add local nomad 2024-01-23 21:15:50 +01:00
lib configure ssh keys 2024-01-15 22:07:10 +01:00
ssh-keys configure ssh keys 2024-01-15 22:07:10 +01:00
.auto.tfvars.enc.yaml secrets: tf provider sops -> tfvars 2024-01-20 20:45:19 +01:00
.envrc poc: terranix 2024-01-13 16:31:46 +01:00
.gitignore secrets: tf provider sops -> tfvars 2024-01-20 20:45:19 +01:00
.sops.yaml secrets: tf provider sops -> tfvars 2024-01-20 20:45:19 +01:00
.terraform.lock.hcl add local nomad 2024-01-23 21:15:50 +01:00
.terraformignore secrets: tf provider sops -> tfvars 2024-01-20 20:45:19 +01:00
.woodpecker.yml fix ci to use nix 2024-01-17 02:37:31 +01:00
README.md add local nomad 2024-01-23 21:15:50 +01:00
config.nix secrets: tf provider sops -> tfvars 2024-01-20 20:45:19 +01:00
flake.lock add local nomad 2024-01-23 21:15:50 +01:00
flake.nix add local nomad 2024-01-23 21:15:50 +01:00
nomad.nix add local nomad 2024-01-23 21:15:50 +01:00
treefmt.toml poc: terranix 2024-01-13 16:31:46 +01:00

README.md

tofu

Contains OpenTofu code used to manage our infrastructure, Nix'ified for Terranix.

Prerequisites

Usage

Development shell

Before issuing any other commands, enter the development environment (if not using direnv):

nix develop -c $SHELL

Handling credentials

Applying changes

nix run

Validating logic

nix run .#check

Showing the generated plan

nix run .#plan

Applying changes, approving automatically

nix run .#cd

Removing local state and derived credentials

nix run .#destroy

Running Nomad jobs locally

nix run .#local

Updating dependencies

nix flake update

Simulating a CI test

substituting <SOPS_AGE_KEY>, run:

woodpecker-cli exec --env "SOPS_AGE_KEY=<SOPS_AGE_KEY>"

Secrets

  • if you want to reset secrets:

    • generate an age key pair, using rage installed as part of the nix shell:

      rage-keygen -o keys.txt
      
    • list it in sops config file .sops.yaml

  • key setup: set environment variable SOPS_AGE_KEY_FILE or SOPS_AGE_KEY so sops can locate the secret key to an age key pair that has its public key listed in .sops.yaml, e.g.:

    export SOPS_AGE_KEY_FILE=./keys.txt
    
  • encoding secrets:

    nix run .#encode
    
  • decoding secrets:

    nix run .#decode
    
  • setting Terraform Cloud credentials, either by:

    • decode (as per above) to reuse the shared session

    • log in to the Terraform Cloud backend:

      tofu login app.terraform.io
      

Configuring

In .auto.tfvars.json override any OpenTofu variables, e.g.:

hcloud_location = "nbg1"

HCL to Nix