Skip to content

Commit

Permalink
Merge pull request #327 from iamkirkbater/sts-fail-fast
Browse files Browse the repository at this point in the history
fail fast on STS accounts attempting to rotate credentials
  • Loading branch information
openshift-merge-robot authored Feb 13, 2023
2 parents 241ae25 + b8238f4 commit 092594e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/account/generate-secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func newCmdGenerateSecret(streams genericclioptions.IOStreams, flags *genericcli
ops := newGenerateSecretOptions(streams, flags, client)
generateSecretCmd := &cobra.Command{
Use: "generate-secret <IAM User name>",
Short: "Generate IAM credentials secret",
Short: "Generates IAM credentials secret",
Long: "When logged into a hive shard, this generates a new IAM credential secret for a given IAM user",
DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(ops.complete(cmd, args))
Expand Down Expand Up @@ -139,6 +140,10 @@ func (o *generateSecretOptions) run() error {
} else {
return fmt.Errorf("account CR is missing AWS Account ID")
}

if account.Spec.ManualSTSMode {
return fmt.Errorf("Account %s is STS - No IAM User Credentials to Rotate", o.accountName)
}
} else {
accountID = o.accountID
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/account/rotate-secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ import (
func newCmdRotateSecret(streams genericclioptions.IOStreams, flags *genericclioptions.ConfigFlags, client client.Client) *cobra.Command {
ops := newRotateSecretOptions(streams, flags, client)
rotateSecretCmd := &cobra.Command{
Use: "rotate-secret <IAM User name>",
Use: "rotate-secret <aws-account-cr-name>",
Short: "Rotate IAM credentials secret",
Long: "When logged into a hive shard, this rotates IAM credential secrets for a given `account` CR.",
DisableAutoGenTag: true,
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(ops.complete(cmd, args))
Expand Down Expand Up @@ -95,6 +96,9 @@ func (o *rotateSecretOptions) run() error {
if err != nil {
return err
}
if account.Spec.ManualSTSMode {
return fmt.Errorf("Account %s is STS - No IAM User Credentials to Rotate", o.accountCRName)
}

// Set the account ID
accountID = account.Spec.AwsAccountID
Expand Down

0 comments on commit 092594e

Please sign in to comment.