-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws.plugin.nu
32 lines (27 loc) · 844 Bytes
/
aws.plugin.nu
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
def-env asp [
profile?: string
login?: string
] {
if ($profile == null) {
hide-env --ignore-errors AWS_DEFAULT_PROFILE
hide-env --ignore-errors AWS_PROFILE
hide-env --ignore-errors AWS_EB_PROFILE
hide-env --ignore-errors AWS_PROFILE_REGION
print "AWS profile cleared."
return
}
let available_profiles = (aws --no-cli-pager configure list-profiles | lines)
if ($available_profiles | find $profile | is-empty) {
print -e $"(ansi red)Profile ($profile) is not found."
print -e $"Available profiles \(($available_profiles | str join ', ')\)(ansi reset)"
return
}
let-env AWS_DEFAULT_PROFILE = $profile
let-env AWS_PROFILE = $profile
let-env AWS_EB_PROFILE = $profile
let-env AWS_PROFILE_REGION = (aws configure get region)
if ($login == "login") {
aws sso login
return
}
}