From cc2b037fd5db927d32b8dd0780a2b6e9da40fdc3 Mon Sep 17 00:00:00 2001 From: Maciej Radzikowski Date: Mon, 21 Oct 2024 13:42:15 +0200 Subject: [PATCH] fix: base fixing path metadata on existing paths --- src/fixPathsMetadataAspect.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/fixPathsMetadataAspect.ts b/src/fixPathsMetadataAspect.ts index 24e3cec..cae03fb 100644 --- a/src/fixPathsMetadataAspect.ts +++ b/src/fixPathsMetadataAspect.ts @@ -3,12 +3,11 @@ import {IConstruct} from 'constructs'; export class FixPathsMetadataAspect implements IAspect { public visit(node: IConstruct): void { - const possibleL1 = node.node.defaultChild ? node.node.defaultChild : node; - if (possibleL1 instanceof CfnResource && node.node.path) { + if (node instanceof CfnResource && typeof node.getMetadata('aws:cdk:path') === 'string') { const stackId = Stack.of(node).node.id; - const parts = node.node.path.split('/'); + const parts = (node.getMetadata('aws:cdk:path') as string).split('/'); if (parts.indexOf(stackId) !== -1) { - possibleL1.addMetadata('aws:cdk:path', parts.slice(parts.indexOf(stackId)).join('/')); + node.addMetadata('aws:cdk:path', parts.slice(parts.indexOf(stackId)).join('/')); } } }