-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy
executable file
·61 lines (54 loc) · 1.22 KB
/
deploy
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
#!/bin/bash
function cleanup() {
pushd compose || exit 1
docker compose -p boundary rm -fsv
popd || exit 1
pushd terraform || exit 1
rm terraform.tfstate*
popd || exit 1
exit 0
}
trap cleanup SIGINT
function init_compose() {
pushd compose || exit 1
docker compose --project-name boundary up -d
popd || exit 1
}
function init_terraform() {
pushd terraform || exit 1
terraform init
terraform apply -auto-approve
popd || exit 1
}
# 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() {
boundary scopes list -format json | jq -r -c '.items[] | select(.name | contains("primary")) | .["id"]'
}
function primary_org_ampw() {
boundary auth-methods list -scope-id "$(primary_org_id)" -format json | jq -r -c '.items[]["id"]'
}
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