Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

paging snsClient.list_subscriptions() #10

@ghost

Description

snsClient.list_subscriptions() seems to be returning 6 endpoints and paging 7+ to next page.
workarround as follow:

@@ -163,14 +163,17 @@ def lambda_handler(event, context):
 
             # If tasks are still running...
             if tasksRunning == 1:
-                response = snsClient.list_subscriptions()
-                for key in response['Subscriptions']:
-                    logger.info("Endpoint %s AND TopicArn %s and protocol %s ",key['Endpoint'], key['TopicArn'],
-                                                                                  key['Protocol'])
-                    if TopicArn == key['TopicArn'] and key['Protocol'] == 'lambda':
-                        logger.info("TopicArn match, publishToSNS function...")
-                        msgResponse = publishToSNS(message, key['TopicArn'])
-                        logger.debug("msgResponse %s and time is %s",msgResponse, datetime.datetime)
+                paginator = snsClient.get_paginator('list_subscriptions')
+                subscriptionListPages = paginator.paginate()
+                for subscriptionListResp in subscriptionListPages:
+                    #response = snsClient.list_subscriptions()
+                    for key in subscriptionListResp['Subscriptions']:
+                        logger.info("Endpoint %s AND TopicArn %s and protocol %s ",key['Endpoint'], key['TopicArn'],
+                                                                                      key['Protocol'])
+                        if TopicArn == key['TopicArn'] and key['Protocol'] == 'lambda':
+                            logger.info("TopicArn match, publishToSNS function...")
+                            msgResponse = publishToSNS(message, key['TopicArn'])
+                            logger.debug("msgResponse %s and time is %s",msgResponse, datetime.datetime)
             # If tasks are NOT running...
             elif tasksRunning == 0:
                 completeHook = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions