-
Notifications
You must be signed in to change notification settings - Fork 2
/
.justfile
121 lines (97 loc) · 3.06 KB
/
.justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
####################################################################################################
# Author: Lior Dux @zMynxx
# Description: A Justfile for managing Sops and age
# Usage: just --list
# Taken from: https://github.com/zMynxx/Toolbox/blob/feature/sops-aghe/mozilla-sops/README.md
# License: MIT
# Version: 0.1
####################################################################################################
#!/usr/bin/env -S just --justfile
# ^ A shebang isn't required, but allows a justfile to be executed
# like a script, with `./justfile test`, for example.
set ignore-comments := false
set positional-arguments := true
log := "warn"
#############
## Chooser ##
#############
# Run fuzzy finder selector
default:
@just --choose
#############
## Install ##
#############
# Install Sops
install-sops:
@echo "Installing Sops using Homebrew..."
brew install sops
# Install Age
install-age:
@echo "Installing Age using Homebrew..."
brew install age
# Install Sops plugin for vscode
install-code-sops:
@echo "Installing Sops plugin for vscode..."
code --install-extension signageos.signageos-vscode-sops --install-extension mikestead.dotenv
###############
## Configure ##
###############
# Configure Sops with a KMS key
config-kms:
@echo "Ensure you have the AWS CLI installed and configured with the right profile!"
@echo "Configuring Sops with kms..."
echo 'awsProfile: ${AWS_PROFILE:-default}' >> .sopsrc
cat <<-YAML > .sops.yaml
creation_rules:
- path_regex: .yaml$
- kms: $(aws kms list-keys --output json | jq -r '.Keys[] | .KeyArn' | fzf)
YAML
# Run the build command
config-age:
@echo "Configuring Sops with Age..."
mkdir -p ~/.sops/age
age-keygen -o ~/.sops/age/key.txt
echo 'export SOPS_AGE_KEY_FILE="$HOME/.sops/age/key.txt" >> ~/.zshrc'
source ~/.zshrc
echo 'ageKeyFile: ~/.sops/age/key.txt' >> .sopsrc
cat <<-YAML > .sops.yaml
creation_rules:
- path_regex: .yaml$
- age: $(cat $SOPS_AGE_KEY_FILE | grep -o "public key: .*" | awk '{print $NF}')
YAML
################
## Encryption ##
################
# Encrypt a file
encrypt *FILE:
@echo "Encrypting *FILE..."
sops --encrypt --in-place {{FILE}}
################
## Decryption ##
################
# Encrypt a file
decrypt *FILE:
@echo "Decrypting *FILE..."
sops --decrypt --in-place {{FILE}}
#############
# Terraform #
#############
# Create a new Terraform module
create-tf-module *NAME:
@echo "Creating a new Terraform module..."
@bash ./scripts/create-module.sh {{NAME}}
# Create documentation for a Terraform module
create-tf-docs *NAME:
@echo "Creating documentation for {{NAME}} module..."
@bash ./scripts/create-docs.sh {{NAME}}
##############
# Terragrunt #
##############
# Build folder structure
build-folder-structure:
@echo "Building folder structure..."
bash ./scripts/build-folder-structure.sh
# Create a new Terragrunt module
create-tg-module *NAME:
@echo "Creating a new Terragrunt module..."
@bash ./scripts/create-terragrunt-module.sh {{NAME}}