Go to file
Kiara Grouwstra 1bda4d5e9c fix ci to use nix 2024-01-17 02:37:31 +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
.envrc poc: terranix 2024-01-13 16:31:46 +01:00
.gitignore fix ci to use nix 2024-01-17 02:37:31 +01:00
.sops.yaml allow sharing secrets using sops + age/rage 2024-01-16 18:02:43 +01:00
.terraform.lock.hcl save server state to local file 2024-01-16 20:08:48 +01:00
.woodpecker.yml fix ci to use nix 2024-01-17 02:37:31 +01:00
README.md fix ci to use nix 2024-01-17 02:37:31 +01:00
config.nix share state: terraform cloud 2024-01-16 20:06:59 +01:00
flake.lock poc: terranix 2024-01-13 16:31:46 +01:00
flake.nix fix ci to use nix 2024-01-17 02:37:31 +01:00
secrets.enc.yaml fix ci to use nix 2024-01-17 02:37:31 +01:00
treefmt.toml poc: terranix 2024-01-13 16:31:46 +01:00

README.md

terraform

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

Prerequisites

Usage

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

    nix develop -c $SHELL
    
  • 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
    
  • Updating dependencies:

    nix flake update
    
  • Simulating a CI test (substituting <SOPS_AGE_KEY>):

    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

  • encoding secrets:

    sops -e secrets.yaml > secrets.enc.yaml
    
  • decoding secrets:

    sops -d secrets.enc.yaml > secrets.yaml
    
  • setting Terraform Cloud credentials, either by:

    • reusing the shared session:

      source login.sh
      
    • log in to the Terraform Cloud backend:

      tofu login app.terraform.io
      

Configuring

Create a file terraform.tfvars containing override for any Terraform variables, e.g.:

hcloud_location = "nbg1"

Managed state

HCL to Nix