Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
fix: add cfn condition for auto-configure resources
Browse files Browse the repository at this point in the history
as workaround when provisioning EKS v1.19
  • Loading branch information
zxkane committed Jun 10, 2021
1 parent 368dd3d commit f309979
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib/sonatype-nexus3-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export class SonatypeNexus3Stack extends cdk.Stack {
const importedEks = this.node.tryGetContext('importedEKS') ?? false;
var cluster: eks.ICluster;
var nodeGroup: eks.Nodegroup;
var eksVersion: cdk.CfnParameter;

const nexusBlobBucket = new s3.Bucket(this, 'nexus3-blobstore', {
removalPolicy: cdk.RemovalPolicy.RETAIN,
Expand Down Expand Up @@ -175,7 +176,7 @@ export class SonatypeNexus3Stack extends cdk.Stack {

const isFargetEnabled = (this.node.tryGetContext('enableFarget') || 'false').toLowerCase() === 'true';

const eksVersion = new cdk.CfnParameter(this, 'KubernetesVersion', {
eksVersion = new cdk.CfnParameter(this, 'KubernetesVersion', {
type: 'String',
allowedValues: [
'1.20',
Expand Down Expand Up @@ -632,6 +633,17 @@ export class SonatypeNexus3Stack extends cdk.Stack {
},
});
nexus3AutoConfigureCR.node.addDependency(nexus3Chart);

const addCondition = (): void => {
if (eksVersion) {
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;
}
};
addCondition();
}
}

Expand Down
1 change: 1 addition & 0 deletions test/sonatype-nexus3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ describe('Nexus OSS stack', () => {
DependsOn: [
'NexusClusterchartNexus37BADE970',
],
Condition: 'EKSV119',
}, ResourcePart.CompleteDefinition);
});

Expand Down

0 comments on commit f309979

Please sign in to comment.