-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsts.go
More file actions
32 lines (28 loc) · 810 Bytes
/
sts.go
File metadata and controls
32 lines (28 loc) · 810 Bytes
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
package cmd
import (
"github.com/Method-Security/methodaws/internal/sts"
"github.com/spf13/cobra"
)
// InitStsCommand initializes the `methodaws ec2` subcommand that is responsible for interacting with the AWS STS service.
func (a *MethodAws) InitStsCommand() {
stsCmd := &cobra.Command{
Use: "sts",
Short: "Leverage STS to manage temporary credentials",
Long: "Leverage STS to manage temporary credentials",
}
arnCmd := &cobra.Command{
Use: "arn",
Short: "Get the caller ARN",
Long: "Get the caller ARN",
Run: func(cmd *cobra.Command, args []string) {
arn, err := sts.GetCallerArn(cmd.Context(), *a.AwsConfig)
if err != nil {
a.OutputSignal.AddError(err)
return
}
a.OutputSignal.Content = arn
},
}
stsCmd.AddCommand(arnCmd)
a.RootCmd.AddCommand(stsCmd)
}