From 73526f47164b2fb9f25237d1c62aa1e399243c6d Mon Sep 17 00:00:00 2001 From: Mengxin Zhu Date: Wed, 16 Jun 2021 04:40:32 +0000 Subject: [PATCH] fix: validation error when deploying EKS with v1.19. --- src/lib/sonatype-nexus3-stack.ts | 15 +++++++++++++-- test/sonatype-nexus3.test.ts | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/lib/sonatype-nexus3-stack.ts b/src/lib/sonatype-nexus3-stack.ts index a3c3162..c00d4e2 100644 --- a/src/lib/sonatype-nexus3-stack.ts +++ b/src/lib/sonatype-nexus3-stack.ts @@ -639,8 +639,19 @@ export class SonatypeNexus3Stack extends cdk.Stack { const eksV119 = new cdk.CfnCondition(this, 'EKSV1.19', { expression: cdk.Fn.conditionNot(cdk.Fn.conditionEquals('1.19', eksVersion.valueAsString)), }); - (autoConfigureFunc.node.defaultChild as lambda.CfnFunction).cfnOptions.condition = eksV119; - (nexus3AutoConfigureCR.node.defaultChild as cdk.CfnCustomResource).cfnOptions.condition = eksV119; + autoConfigureFunc.node.children.forEach(r => { + if (r instanceof cdk.CfnResource) { + (r as cdk.CfnResource).cfnOptions.condition = eksV119; + } else { + r.node.children.forEach(r1 => { + if (r1 instanceof cdk.CfnResource) { + (r1 as cdk.CfnResource).cfnOptions.condition = eksV119; + } + }); + } + + }); + nexus3AutoConfigureCR.node.children.forEach(r => { (r as cdk.CfnResource).cfnOptions.condition = eksV119; }); } }; addCondition(); diff --git a/test/sonatype-nexus3.test.ts b/test/sonatype-nexus3.test.ts index 93b83f8..eae5a54 100644 --- a/test/sonatype-nexus3.test.ts +++ b/test/sonatype-nexus3.test.ts @@ -302,6 +302,23 @@ describe('Nexus OSS stack', () => { ], Condition: 'EKSV119', }, ResourcePart.CompleteDefinition); + + expect(stack).toHaveResourceLike('Custom::LogRetention', { + Properties: { + LogGroupName: { + 'Fn::Join': [ + '', + [ + '/aws/lambda/', + { + Ref: 'Neuxs3AutoCofingureE91D0A63', + }, + ], + ], + }, + }, + Condition: 'EKSV119', + }, ResourcePart.CompleteDefinition); }); test('AWS load baalancer controller helm chart is created', () => {