From 7120a6529230bdea9c3f9fc052ace1486ff72ca1 Mon Sep 17 00:00:00 2001 From: Will Dady Date: Mon, 11 Apr 2022 15:28:18 +1000 Subject: [PATCH] fix: handle not-found policies for EventBridge schema registries --- src/schemas/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 575d57f..d3936ad 100755 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -1,5 +1,6 @@ import { GetResourcePolicyCommand, + NotFoundException, paginateListRegistries, RegistrySummary, SchemasClient, @@ -38,7 +39,15 @@ export class EventBridgeSchemasPolicyCollector extends BasePolicyCollector { for (const r of registries) { // NOTE: Can not read policies of AWS managed registries if (r.RegistryName!.startsWith('aws.')) continue; - const response = await this.getResourcePolicy(r.RegistryName!); + let response; + try { + response = await this.getResourcePolicy(r.RegistryName!); + } catch (err) { + if (err instanceof NotFoundException) { + continue; + } + throw err; + } if (!response.Policy) continue; result.resources.push({ type: 'AWS::EventSchemas::Registry',