-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·67 lines (59 loc) · 1.24 KB
/
run
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
#!/bin/bash
function cleanup() {
pushd compose
docker compose -p boundary rm -fs
popd
pushd terraform/
rm terraform.tfstate*
rm -rf .terraform
rm .terraform.lock.hcl
popd
exit 0
}
trap cleanup SIGKILL SIGINT
function init_compose() {
pushd compose/
docker compose --project-name boundary up -d
popd
}
function init_terraform() {
pushd terraform
terraform init
terraform apply -auto-approve
popd
}
# Test with login to Boundary after provisioning
function login() {
boundary authenticate password -login-name user1 -password password -auth-method-id $(primary_org_ampw)
}
function primary_org_id() {
strip $(boundary scopes list -format json | jq -c '.[] | select(.name | contains("primary")) | .["id"]')
}
function primary_org_ampw() {
strip $(boundary auth-methods list -scope-id $(primary_org_id) -format json | jq -c '.[]["id"]')
}
function strip() {
echo "$1" | tr -d '"'
}
for arg in "$@"
do
case $arg in
all)
init_compose
init_terraform
shift
;;
login)
login
shift
;;
cleanup)
cleanup
shift
;;
*)
echo "cmd not found: try 'all', 'login', or 'cleanup'"
shift
;;
esac
done