-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.amazon.aliases
More file actions
68 lines (57 loc) · 1.93 KB
/
Copy path.amazon.aliases
File metadata and controls
68 lines (57 loc) · 1.93 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
59
60
61
62
63
64
65
66
67
68
alias bb='brazil-build'
alias bbr='brazil-build release'
alias bup='brazil ws use --package'
alias brp='brazil ws remove --package'
alias bws='brazil ws --sync --md'
alias ssh-dev='ssh -t "$DEV_DESKTOP_HOST" "tmux -u -CC new -A -s main"'
alias journal='/apollo/env/JournalClientCLI/bin/journal'
# Git worktrees can break cr's workspace detection because the worktree path
# may not match packageInfo. Extract the version set and pass it through.
alias cr='command cr --vs "$(brazil ws show -f json | jq -r .version_set.name)"'
instanceid() {
local node="${1:-}"
if [[ -z "$node" ]]; then
printf 'usage: instanceid NODE\n' >&2
return 2
fi
kubectl get node "$node" -o json | jq -r '.spec.providerID' | awk -F/ '{print $NF}'
}
ssmnode() {
local node="${1:-}"
if [[ -z "$node" ]]; then
printf 'usage: ssmnode NODE\n' >&2
return 2
fi
aws ssm start-session --target "$(instanceid "$node")"
}
ssmportforward() {
local node="${1:-}"
local remote_port="${2:-1234}"
local local_port="${3:-$remote_port}"
if [[ -z "$node" ]]; then
printf 'usage: ssmportforward NODE [REMOTE_PORT] [LOCAL_PORT]\n' >&2
return 2
fi
aws ssm start-session \
--target "$(instanceid "$node")" \
--document-name AWS-StartPortForwardingSession \
--parameters "{\"portNumber\":[\"$remote_port\"],\"localPortNumber\":[\"$local_port\"]}"
}
ecr_login() {
local region="${1:-${AWS_DEFAULT_REGION:-us-west-2}}"
local account="${2:-$(aws_account)}"
aws ecr get-login-password --region "$region" |
docker login --username AWS --password-stdin "$account.dkr.ecr.$region.amazonaws.com"
}
aws_login() {
local account="${1:-$(aws_account)}"
local role="${2:-${AWS_ACCOUNT_ROLE:-Admin}}"
local url="https://isengard.amazon.com/federate?account=$account&role=$role"
if command -v open >/dev/null 2>&1; then
open "$url"
elif command -v xdg-open >/dev/null 2>&1; then
xdg-open "$url"
else
printf '%s\n' "$url"
fi
}