diff --git a/cmd/deploy.go b/cmd/deploy.go index 210570a..dab5909 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -144,7 +144,7 @@ func deploy(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "failed to write params") } - fmt.Printf("%d new configs deployed. service = %s, stage = %s", len(configsToDeploy), config.Service, stage) + fmt.Printf("%d new configs deployed. service = %s, stage = %s\n", len(configsToDeploy), config.Service, stage) return nil } diff --git a/cmd/list.go b/cmd/list.go index f718c6d..c0fc842 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -86,6 +86,10 @@ func printList(configs []store.Config) { fmt.Fprintln(w, "") } + fmt.Fprintln(w, "---") + fmt.Fprintf(w, "Total parameters = %d", len(configs)) + fmt.Fprintln(w, "") + w.Flush() } diff --git a/example/safebox.yml b/example/safebox.yml index d729a4e..7702695 100644 --- a/example/safebox.yml +++ b/example/safebox.yml @@ -7,9 +7,14 @@ cloudformation-stacks: config: defaults: DB_NAME: "database name updated" - API_ENDPOINT: "{{.authorizerLambaArns}}" + API_ENDPOINT: "{{.internalDomainName}}" NEW: "endpoint-{{.stage}}" NEW2: "endpoint updated" + NEW3: "endpoint updated" + NEW4: "endpoint updated" + NEW5: "endpoint updated" + NEW6: "endpoint updated" + NEW7: "endpoint updated" prod: DB_NAME: "production db name" diff --git a/npm/package-lock.json b/npm/package-lock.json index 4dd1b2b..dc283f9 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -1,12 +1,12 @@ { "name": "@adikari/safebox", - "version": "1.1.5", + "version": "1.1.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@adikari/safebox", - "version": "1.1.5", + "version": "1.1.7", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/npm/package.json b/npm/package.json index 88ade55..1f636bc 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,11 +1,9 @@ { "name": "@adikari/safebox", - "version": "1.1.6", + "version": "1.1.8", "description": "A Fast and Flexible secret manager built with love by adikari in Go", "main": "index.js", - "bin": { - "safebox": "./run.js" - }, + "bin": "./run.js", "scripts": { "postinstall": "node install.js install", "preuninstall": "node install.js uninstall", diff --git a/store/ssmstore.go b/store/ssmstore.go index 1606d81..f8e3303 100644 --- a/store/ssmstore.go +++ b/store/ssmstore.go @@ -3,6 +3,7 @@ package store import ( "strings" + "github.com/adikari/safebox/v2/util" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/client" "github.com/aws/aws-sdk-go/aws/session" @@ -98,21 +99,36 @@ func (s *SSMStore) GetMany(configs []ConfigInput) ([]Config, error) { return []Config{}, nil } - getParametersInput := &ssm.GetParametersInput{ - Names: getNames(configs), - WithDecryption: aws.Bool(true), - } + get := func(c []ConfigInput) ([]Config, error) { + var res []Config - resp, err := s.svc.GetParameters(getParametersInput) + getParametersInput := &ssm.GetParametersInput{ + Names: getNames(c), + WithDecryption: aws.Bool(true), + } - if err != nil { - return []Config{}, err + resp, err := s.svc.GetParameters(getParametersInput) + + if err != nil { + return []Config{}, err + } + + for _, param := range resp.Parameters { + res = append(res, parameterToConfig(param)) + } + + return res, nil } var params []Config + for _, chunk := range util.ChunkSlice(configs, 10) { + p, err := get(chunk) + + if err != nil { + return []Config{}, err + } - for _, param := range resp.Parameters { - params = append(params, parameterToConfig(param)) + params = append(params, p...) } return params, nil diff --git a/util/util.go b/util/util.go new file mode 100644 index 0000000..b0ae4e4 --- /dev/null +++ b/util/util.go @@ -0,0 +1,16 @@ +package util + +func ChunkSlice[T any](slice []T, chunkSize int) [][]T { + var chunks [][]T + for i := 0; i < len(slice); i += chunkSize { + end := i + chunkSize + + if end > len(slice) { + end = len(slice) + } + + chunks = append(chunks, slice[i:end]) + } + + return chunks +}