Skip to content

Commit 5845d28

Browse files
fix(core): Fixing Log Group creation for Public Hosted Zone logging (#406)
1 parent cb74a1f commit 5845d28

File tree

2 files changed

+18
-3
lines changed
  • src
    • deployments/cdk/src/apps
    • lib/custom-resources/cdk-associate-hosted-zones/runtime/src

2 files changed

+18
-3
lines changed

src/deployments/cdk/src/apps/phase-1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export async function deploy({ acceleratorConfig, accountStacks, accounts, conte
506506
acceleratorPrefix: context.acceleratorPrefix,
507507
domain: phz,
508508
});
509-
return new LogGroup(zonesStack, `Route53HostedZoneLogGroup`, {
509+
return new LogGroup(zonesStack, `Route53HostedZoneLogGroup${pascalCase(phz)}`, {
510510
logGroupName,
511511
roleArn: logGroupLambdaRoleOutput.roleArn,
512512
});

src/lib/custom-resources/cdk-associate-hosted-zones/runtime/src/index.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,16 @@ async function onUpdate(event: CloudFormationCustomResourceUpdateEvent) {
211211
};
212212
// authorize association of VPC with Hosted zones when VPC and Hosted Zones are defined in two different accounts
213213
if (vpcAccountId !== hostedZoneAccountId) {
214-
await throttlingBackOff(() => hostedZoneRoute53.createVPCAssociationAuthorization(hostedZoneProps).promise());
214+
try {
215+
await throttlingBackOff(() => hostedZoneRoute53.createVPCAssociationAuthorization(hostedZoneProps).promise());
216+
} catch (e) {
217+
if (e.code === 'NoSuchHostedZone') {
218+
console.info(`No Domain exists with ID "${hostedZoneId}"; ignore this error and continue`);
219+
continue;
220+
} else {
221+
throw new Error(e);
222+
}
223+
}
215224
}
216225

217226
// associate VPC with Hosted zones
@@ -273,7 +282,13 @@ async function onDelete(event: CloudFormationCustomResourceDeleteEvent) {
273282
};
274283
// authorize association of VPC with Hosted zones when VPC and Hosted Zones are defined in two different accounts
275284
if (vpcAccountId !== hostedZoneAccountId) {
276-
await throttlingBackOff(() => hostedZoneRoute53.createVPCAssociationAuthorization(hostedZoneProps).promise());
285+
try {
286+
await throttlingBackOff(() => hostedZoneRoute53.createVPCAssociationAuthorization(hostedZoneProps).promise());
287+
} catch (e) {
288+
console.error(`Ignoring error while deleting Association and stack ${hostedZoneId} to VPC "${vpcName}"`);
289+
console.error(e);
290+
continue;
291+
}
277292
}
278293

279294
// associate VPC with Hosted zones

0 commit comments

Comments
 (0)