Skip to content

Commit 4a64117

Browse files
authored
Paginate through results in order to get them all (#1)
1 parent 9bdd8e7 commit 4a64117

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

ssm.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,23 @@ func Parse(path string) error {
2828
Path: aws.String(path),
2929
WithDecryption: aws.Bool(true),
3030
}
31-
out, err := svc.GetParametersByPath(&input)
31+
var internalErr error
32+
err = svc.GetParametersByPathPages(&input, func(out *ssm.GetParametersByPathOutput, lastPage bool) bool {
33+
for _, param := range out.Parameters {
34+
name := strings.TrimPrefix(aws.StringValue(param.Name), path)
35+
internalErr = os.Setenv(name, aws.StringValue(param.Value))
36+
if internalErr != nil {
37+
return false
38+
}
39+
}
40+
return true
41+
})
3242
if err != nil {
3343
return err
3444
}
35-
for _, param := range out.Parameters {
36-
name := strings.TrimPrefix(aws.StringValue(param.Name), path)
37-
err := os.Setenv(name, aws.StringValue(param.Value))
38-
if err != nil {
39-
return err
40-
}
45+
if internalErr != nil {
46+
return internalErr
4147
}
48+
4249
return nil
4350
}

0 commit comments

Comments
 (0)