@@ -19,13 +19,21 @@ import awsLoggerText from '../../properties/logger'
1919import { AwsTag , TagMap } from '../../types'
2020import { convertAwsTagsToTagMap } from '../../utils/format'
2121import AwsErrorLog from '../../utils/errorLog'
22- import { initTestEndpoint } from '../../utils'
22+ import { initTestEndpoint , setAwsRetryOptions } from '../../utils'
23+ import {
24+ API_GATEWAY_CUSTOM_DELAY ,
25+ MAX_FAILED_AWS_REQUEST_RETRIES ,
26+ } from '../../config/constants'
2327
2428const lt = { ...awsLoggerText }
2529const { logger } = CloudGraph
2630const serviceName = 'SNS'
2731const errorLog = new AwsErrorLog ( serviceName )
2832const endpoint = initTestEndpoint ( serviceName )
33+ const customRetrySettings = setAwsRetryOptions ( {
34+ maxRetries : MAX_FAILED_AWS_REQUEST_RETRIES ,
35+ baseDelay : API_GATEWAY_CUSTOM_DELAY ,
36+ } )
2937
3038/**
3139 * SNS
@@ -155,14 +163,19 @@ const getTopicSubscriptions = async (
155163 sns . listSubscriptionsByTopic (
156164 listSubscriptionsOpts ,
157165 ( err : AWSError , data : ListSubscriptionsByTopicResponse ) => {
158- const { Subscriptions, NextToken } = data || { }
159166 if ( err ) {
160167 errorLog . generateAwsErrorLog ( {
161168 functionName : 'sns:listSubscriptionsByTopic' ,
162169 err,
163170 } )
164171 }
165172
173+ if ( isEmpty ( data ) ) {
174+ resolveSubscriptions ( [ ] )
175+ }
176+
177+ const { Subscriptions, NextToken } = data || { }
178+
166179 subscriptions . push ( ...Subscriptions )
167180
168181 if ( NextToken ) {
@@ -196,7 +209,12 @@ export default async ({
196209
197210 // First we get all sns topics arn for all regions
198211 regions . split ( ',' ) . map ( region => {
199- const sns = new SNS ( { ...config , region, endpoint } )
212+ const sns = new SNS ( {
213+ ...config ,
214+ region,
215+ endpoint,
216+ ...customRetrySettings ,
217+ } )
200218 const regionPromise = new Promise < void > ( async resolveRegion => {
201219 const snsTopicArnList = await listSnsTopicArnsForRegion ( {
202220 sns,
0 commit comments