File tree 1 file changed +38
-0
lines changed 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # This alias lets you choose your aws environment variables with ease.
2
+ #
3
+ # Dependencies
4
+ # * fzf
5
+ #
6
+ # Installation
7
+ # 1. store in ~/.config/nushell/select-aws-profile.nu
8
+ # 2. add to your config.nu: `use ~/.config/nushell/select-aws-profile.nu *`
9
+ #
10
+ # Usage
11
+ # select-aws-profile
12
+
13
+ export alias select-aws-profile = (
14
+ hide AWS_REGION;
15
+ (do {
16
+ let creds = (open ($env .HOME + " /.aws/credentials" ) | from ini )
17
+ let selectedProfile = (for it in ($creds | transpose name creds ) { echo $it.name } | str collect " \n " | fzf | str trim )
18
+ if $selectedProfile != " " {
19
+ let out = {
20
+ AWS_PROFILE : $selectedProfile ,
21
+ AWS_ACCESS_KEY_ID : ($creds | get $selectedProfile | get " aws_access_key_id" ),
22
+ AWS_SECRET_ACCESS_KEY : ($creds | get $selectedProfile | get " aws_secret_access_key" ),
23
+ }
24
+ let region = ($creds | get $selectedProfile | get - i " region" )
25
+ if $region != " " {
26
+ $out | insert " AWS_REGION" $region
27
+ } else {
28
+ $out
29
+ }
30
+ }
31
+ } | load-env );
32
+ {
33
+ AWS_PROFILE : $env .AWS_PROFILE ,
34
+ AWS_ACCESS_KEY_ID : $env .AWS_ACCESS_KEY_ID ,
35
+ AWS_SECRET_ACCESS_KEY : $env .AWS_SECRET_ACCESS_KEY ,
36
+ AWS_REGION : $env .AWS_REGION
37
+ }
38
+ )
You can’t perform that action at this time.
0 commit comments