-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtoggle-gui.sh
More file actions
58 lines (47 loc) · 1.86 KB
/
toggle-gui.sh
File metadata and controls
58 lines (47 loc) · 1.86 KB
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
#!/usr/bin/env bash
set -euo pipefail
STACK_NAME="${1:-heimdall}"
AWS_REGION="${AWS_REGION:-eu-north-1}"
echo "Looking up stack: $STACK_NAME (region: $AWS_REGION)"
# Get current EnableGui value
CURRENT=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" --region "$AWS_REGION" \
--query "Stacks[0].Parameters[?ParameterKey=='EnableGui'].ParameterValue" \
--output text)
if [ "$CURRENT" = "true" ]; then
NEW="false"
else
NEW="true"
fi
echo "EnableGui: $CURRENT -> $NEW"
# Build parameter overrides: flip EnableGui, keep everything else
PARAMS=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" --region "$AWS_REGION" \
--query "Stacks[0].Parameters" \
--output json \
| jq -c '[.[] | if .ParameterKey == "EnableGui" then {ParameterKey: .ParameterKey, ParameterValue: "'"$NEW"'"} else {ParameterKey: .ParameterKey, UsePreviousValue: true} end]')
echo "Updating stack..."
aws cloudformation update-stack \
--stack-name "$STACK_NAME" --region "$AWS_REGION" \
--use-previous-template \
--parameters "$PARAMS" \
--capabilities CAPABILITY_NAMED_IAM
echo "Waiting for stack update to complete (this can take a few minutes)..."
aws cloudformation wait stack-update-complete --stack-name "$STACK_NAME" --region "$AWS_REGION"
echo "Stack update complete."
if [ "$NEW" = "true" ]; then
ALB_DNS=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" --region "$AWS_REGION" \
--query "Stacks[0].Outputs[?OutputKey=='ALBDnsName'].OutputValue" \
--output text)
DOMAIN=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" --region "$AWS_REGION" \
--query "Stacks[0].Parameters[?ParameterKey=='GuiDomainName'].ParameterValue" \
--output text)
echo ""
echo "GUI enabled. Update your DNS:"
echo " $DOMAIN CNAME $ALB_DNS"
else
echo ""
echo "GUI disabled. ALB and Cognito resources removed."
fi