-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrds.go
More file actions
52 lines (44 loc) · 1.32 KB
/
rds.go
File metadata and controls
52 lines (44 loc) · 1.32 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
package cmd
import (
// Generated
rdsfern "github.com/Method-Security/methodaws/generated/go/rds"
// Internal
"github.com/Method-Security/methodaws/internal/rds"
"github.com/Method-Security/methodaws/utils"
// External
"github.com/spf13/cobra"
)
// InitRdsCommand initializes the `methodaws rds` subcommand that deals with enumerating RDS instances in the AWS account.
func (a *MethodAws) InitRdsCommand() {
rdsCmd := &cobra.Command{
Use: "rds",
Short: "Audit and manage RDS instances",
Long: `Audit and manage RDS instances`,
}
enumerateCmd := &cobra.Command{
Use: "enumerate",
Short: "Enumerate RDS instances",
Long: `Enumerate RDS instances in your AWS account.`,
Run: func(cmd *cobra.Command, args []string) {
// Account ID
accountID, err := utils.GetAccountID(cmd.Context(), *a.AwsConfig)
if err != nil {
a.OutputSignal.AddError(err)
return
}
// Config
config := getRdsEnumerateConfig(a.RootFlags.Regions, accountID)
// Report
report := rds.EnumerateRDS(cmd.Context(), *a.AwsConfig, config)
a.OutputSignal.Content = report
},
}
rdsCmd.AddCommand(enumerateCmd)
a.RootCmd.AddCommand(rdsCmd)
}
func getRdsEnumerateConfig(regions []string, accountID string) rdsfern.RdsEnumerateConfig {
return rdsfern.RdsEnumerateConfig{
Regions: regions,
AccountId: accountID,
}
}