Skip to content

Commit

Permalink
*: clean up, set ssm fetch limit
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed May 14, 2020
1 parent 5b4289d commit 23d2185
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 0 additions & 1 deletion eksconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type Config struct {
// KubectlPath is the path to download the "kubectl".
KubectlPath string `json:"kubectl-path,omitempty"`
// KubectlDownloadURL is the download URL to download "kubectl" binary from.
// https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html
KubectlDownloadURL string `json:"kubectl-download-url,omitempty"`
// KubeConfigPath is the file path of KUBECONFIG for the EKS cluster.
// If empty, auto-generate one.
Expand Down
8 changes: 8 additions & 0 deletions pkg/aws/ssm/ssm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package ssm

import (
"fmt"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -14,6 +15,7 @@ import (
type FetchConfig struct {
Logger *zap.Logger
SSMAPI ssmiface.SSMAPI
CommandID string
DocumentName string
InvokedAfter time.Time
BatchLimit int64
Expand All @@ -26,6 +28,9 @@ const rfc3339Micro = "2006-01-02T15:04:05.999Z07:00"
// It only returns the invocation whose status is "Success".
// e.g. aws ssm list-command-invocations --details --filter key=DocumentName,value=ResourceCounterSSMDocDevStack
func FetchOutputs(cfg FetchConfig) (ivs []*ssm.CommandInvocation, err error) {
if cfg.BatchLimit > 50 {
return nil, fmt.Errorf("batch limit exceeded 50, got %v", cfg.BatchLimit)
}
cfg.Logger.Info("fetching SSM doc outputs", zap.String("document-name", cfg.DocumentName), zap.Int64("batch-limit", cfg.BatchLimit))
input := &ssm.ListCommandInvocationsInput{
Details: aws.Bool(true),
Expand All @@ -41,6 +46,9 @@ func FetchOutputs(cfg FetchConfig) (ivs []*ssm.CommandInvocation, err error) {
},
},
}
if cfg.CommandID != "" {
input.CommandId = aws.String(cfg.CommandID)
}
var output *ssm.ListCommandInvocationsOutput
for {
output, err = cfg.SSMAPI.ListCommandInvocations(input)
Expand Down

0 comments on commit 23d2185

Please sign in to comment.