Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2766,11 +2766,17 @@ _account_already_prefixed() {
display_name=$(printf '%s' "$current_name" | tr -d '\000-\037')
ok "Account already named for Loki: $(printf '%s' "$display_name")"
# Write SSM params if they don't exist yet (first install with pre-existing prefix).
# Note: stripped_original is a best-guess — if account was manually named
# "LOKI-Foo", we store "Foo" but the true pre-Loki original is unknown.
# Note: stripped_original is a best-guess — only strip when the name
# has a real "Loki-" / "loki-" separator. For freeform "loki*" matches
# (e.g. "LokiDev-Foo", "loki1-Bar") there is no reliable way to recover
# the pre-Loki name, so fall back to ACCOUNT_ID.
if ! aws ssm get-parameter --name "/loki/original-account-name" \
--region "${DEPLOY_REGION:-$REGION}" --output text >/dev/null 2>&1; then
local stripped_original="${current_name:5}" # strip 5-char prefix (Loki-)
local stripped_original=""
local lower_prefix="${lower_name:0:5}"
if [[ "$lower_prefix" == "loki-" ]]; then
stripped_original="${current_name:5}" # strip exact 5-char "Loki-" prefix
fi
[[ -n "$stripped_original" ]] || stripped_original="$ACCOUNT_ID"
aws ssm put-parameter --name "/loki/original-account-name" \
--value "$stripped_original" --type String --overwrite \
Expand Down
Loading