Only getting partial Secrets list from boto3


I’m having an odd problem with querying AWS SecretsManager using the Python3 boto3 library. When I get a list of secrets I consistenty only get 10 when there’s more than that listed in the web console and it doesn’t include the ones I need. Sample code below.

import json
import boto3
import base64

session = boto3.session.Session('secretsmanager', 'eu-west-2')
client = boto3.client('secretsmanager')


print('Secrets found: '+str(length))

Has anyone else seen this issue?

Edit: after looking at the docs again it looks like it may be because I need to specify a NextToken parameter but I can’t find any examples of what this should look like.

Edit2: it looks like I need to use pagination
Edit3: looks like you can’t paginate this call. Instead use NextToken parameter like:

moreSecrets=client.list_secrets(MaxResults=10, NextToken=secrets['NextToken'])