File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "context"
55 "fmt"
66 "log"
7+ "os"
8+ "strconv"
79 "strings"
810
911 "github.com/aws/aws-sdk-go-v2/service/ssm"
@@ -58,6 +60,21 @@ func FetchKeysOfParameters(
5860 MaxResults : 10 ,
5961 ParameterFilters : parameterFilters ,
6062 }
63+
64+ // CHECKENV_AWS_FETCH_LOOP_LIMIT by default set to 10,
65+ // it is allows to load 100 parameters from AWS and it is
66+ // a limiter to prevent loading too many parameters without
67+ // control during passing erroneous filters
68+ var err error
69+ var fetchLoopLimit int
70+ fetchLoopLimitStr := os .Getenv ("CHECKENV_AWS_FETCH_LOOP_LIMIT" )
71+ if fetchLoopLimitStr != "" {
72+ fetchLoopLimit , err = strconv .Atoi (fetchLoopLimitStr )
73+ }
74+ if fetchLoopLimitStr == "" || err != nil {
75+ fetchLoopLimit = 10
76+ }
77+
6178 n := 0
6279 for {
6380 // Fetch list of parameter keys
@@ -76,7 +93,7 @@ func FetchKeysOfParameters(
7693 describeInput .NextToken = results .NextToken
7794
7895 n ++
79- if n >= 50 {
96+ if n >= fetchLoopLimit {
8097 log .Fatal ("To many iterations over DescribeParameters loop" )
8198 }
8299 }
You can’t perform that action at this time.
0 commit comments