Skip to content

Commit

Permalink
Merge terraform shell.nix with the main shell.nix
Browse files Browse the repository at this point in the history
Remove the separate shell.nix for terraform, merge it with the main
shell.nix. This simplifies the usage as the terraform configuration
can now be done from the main shell.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
  • Loading branch information
henrirosten committed Nov 7, 2023
1 parent 3517bc4 commit 3e61c6e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 38 deletions.
3 changes: 0 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
pkgs = import nixpkgs {inherit system;};
};
ghaf-infra-shell = importExpectingSystem ./shell.nix;
terraform-shell = importExpectingSystem ./terraform/shell.nix;
templateTargets = import ./hosts/templates/targets.nix {inherit nixpkgs disko;};
in {
# nix fmt
Expand All @@ -51,8 +50,6 @@
devShells = forEachSystem (system: {
# nix develop
default = ghaf-infra-shell system;
# nix develop .#terraform
terraform = terraform-shell system;
});

# NixOS configuration entrypoint
Expand Down
8 changes: 7 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
pkgs.mkShell {
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
nativeBuildInputs = with pkgs; [
azure-cli
git
nix
nixos-rebuild
Expand All @@ -30,6 +31,11 @@ pkgs.mkShell {
reuse
sops
ssh-to-age
terraform
(terraform.withPlugins (p: [
p.azurerm
p.external
p.null
p.sops
]))
];
}
15 changes: 9 additions & 6 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0

# Ghaf-infra: Terraform

This project uses terraform to automate the creation of infrastructure resources. The inteded usage together with NixOS configurations in the main [flake.nix](../flake.nix) is as follows:
This project uses terraform to automate the creation of infrastructure resources. The intended usage together with NixOS configurations in the main [flake.nix](../flake.nix) is as follows:
- We use the terraform configuration in this directory for the inital setup of the infrastructure resources (VMs, networks, etc.)
- We use the NixOS configurations in [flake.nix](../flake.nix) to [install](../README.md#install) NixOS on the VMs
- We maintain the infrastructure by [deploying](../README.md#deploy) changes to the NixOS configurations via [flake.nix](../flake.nix)
Expand All @@ -23,15 +23,18 @@ $ git clone https://github.com/tiiuae/ghaf-infra.git
$ cd ghaf-infra
```

All commands in this document are executed from terraform nix-shell inside the `terraform` directory.
All commands in this document are executed from nix-shell inside the `terraform` directory.

Bootstrap terraform nix-shell with the required dependencies:
Bootstrap nix-shell with the required dependencies:
```bash
$ cd terraform
# Start a nix-shell with required dependencies:
$ nix-shell

# Authenticate with az login:
$ az login

# Terraform comands are executed under the terraform directory:
$ cd terraform/
```

## Initializing Azure Storage
Expand All @@ -41,14 +44,14 @@ This project stores the terraform state in a remote storage in an azure storage

When starting a new infrastructure you need to initialize the terraform state storage:
```bash
$ cd azure-storage/
$ cd azure-storage
$ terraform init
$ terraform apply
```

## Terraform workflow

Following describes the intended workflow, with commands executed from the terraform nix-shell.
Following describes the intended workflow, with commands executed from the nix-shell.

First, change the terraform code by modifying the relevant files in this directory. Then:

Expand Down
28 changes: 0 additions & 28 deletions terraform/shell.nix

This file was deleted.

0 comments on commit 3e61c6e

Please sign in to comment.