File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,23 @@ export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
7878export AWS_SESSION_TOKEN=< SESSION_TOKEN>
7979```
8080
81+ #### PowerShell more your thing?
82+
83+ If you're using PowerShell, you can use ` export-ps ` to generate PowerShell assignments, instead.
84+
85+ ``` powershell
86+ > aws-sso-creds export-ps
87+ $env:AWS_ACCESS_KEY_ID='<KEY>'
88+ $env:AWS_SECRET_ACCESS_KEY='<SECRET_KEY>'
89+ $env:AWS_SESSION_TOKEN='<SESSION_TOKEN>'
90+ ```
91+
92+ Use it with ` Invoke-Expression ` :-
93+
94+ ``` powershell
95+ > aws-sso-creds export-ps | Invoke-Expression
96+ ```
97+
8198## List accounts
8299
83100You can also list the accounts you have available within AWS SSO:
Original file line number Diff line number Diff line change 1+ package exportps
2+
3+ import (
4+ "fmt"
5+
6+ "github.com/jaxxstorm/aws-sso-creds/pkg/credentials"
7+ "github.com/spf13/cobra"
8+ "github.com/spf13/viper"
9+ )
10+
11+ func Command () * cobra.Command {
12+ command := & cobra.Command {
13+ Use : "export-ps" ,
14+ Short : "Generates a set of powershell environment assignments to define the AWS temporary creds to your environment" ,
15+ Long : "Generates a set of powershell environment assignments to define the AWS temporary creds to your environment" ,
16+ SilenceUsage : true ,
17+ RunE : func (cmd * cobra.Command , args []string ) error {
18+
19+ cmd .SilenceUsage = true
20+
21+ profile := viper .GetString ("profile" )
22+ homeDir := viper .GetString ("home-directory" )
23+
24+ creds , _ , err := credentials .GetSSOCredentials (profile , homeDir )
25+
26+ if err != nil {
27+ return err
28+ }
29+
30+ fmt .Printf ("$env:AWS_ACCESS_KEY_ID='%s'\n " , * creds .RoleCredentials .AccessKeyId )
31+ fmt .Printf ("$env:AWS_SECRET_ACCESS_KEY='%s'\n " , * creds .RoleCredentials .SecretAccessKey )
32+ fmt .Printf ("$env:AWS_SESSION_TOKEN='%s'\n " , * creds .RoleCredentials .SessionToken )
33+
34+ return nil
35+ },
36+ }
37+
38+ return command
39+ }
Original file line number Diff line number Diff line change 66 "github.com/spf13/viper"
77
88 "github.com/jaxxstorm/aws-sso-creds/cmd/aws-sso-creds/export"
9+ "github.com/jaxxstorm/aws-sso-creds/cmd/aws-sso-creds/exportps"
910 "github.com/jaxxstorm/aws-sso-creds/cmd/aws-sso-creds/get"
1011 "github.com/jaxxstorm/aws-sso-creds/cmd/aws-sso-creds/helper"
1112 "github.com/jaxxstorm/aws-sso-creds/cmd/aws-sso-creds/list"
@@ -29,6 +30,7 @@ func configureCLI() *cobra.Command {
2930 rootCommand .AddCommand (set .Command ())
3031 rootCommand .AddCommand (version .Command ())
3132 rootCommand .AddCommand (export .Command ())
33+ rootCommand .AddCommand (exportps .Command ())
3234 rootCommand .AddCommand (list .Command ())
3335 rootCommand .AddCommand (helper .Command ())
3436
You can’t perform that action at this time.
0 commit comments