File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
packages/amplify-codegen-e2e-tests/src Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -176,11 +176,23 @@ const getOrphanTestIamRoles = async (account: AWSAccountInfo): Promise<IamRoleIn
176
176
const getRegionsEnabled = async ( accountInfo : AWSAccountInfo ) : Promise < string [ ] > => {
177
177
// Specify service region to avoid possible endpoint unavailable error
178
178
const account = new Account ( { ...accountInfo , region : 'us-east-1' } ) ;
179
- const response = await account . listRegions ( ) . promise ( ) ;
180
- const enabledRegions = response . Regions . map ( r =>
181
- r . RegionOptStatus === 'ENABLED' || r . RegionOptStatus === 'ENABLED_BY_DEFAULT' ? r . RegionName : null ,
182
- ) . filter ( Boolean ) ;
183
179
180
+ const enabledRegions : string [ ] = [ ] ;
181
+ let nextToken : string | undefined = undefined ;
182
+
183
+ do {
184
+ const input : Account . Types . ListRegionsRequest = {
185
+ RegionOptStatusContains : [ 'ENABLED' , 'ENABLED_BY_DEFAULT' ] ,
186
+ NextToken : nextToken ,
187
+ } ;
188
+
189
+ const response = await account . listRegions ( input ) . promise ( ) ;
190
+ nextToken = response . NextToken ;
191
+
192
+ enabledRegions . push ( ...response . Regions . map ( r => r . RegionName ) . filter ( Boolean ) ) ;
193
+ } while ( nextToken ) ;
194
+
195
+ console . log ( 'All enabled regions fetched: ' , enabledRegions ) ;
184
196
return enabledRegions ;
185
197
} ;
186
198
You can’t perform that action at this time.
0 commit comments