From c7de4b4a755e7b21d6b5d22ffb3425cd305397ad Mon Sep 17 00:00:00 2001 From: Sayali Gaikawad <61760125+gaiksaya@users.noreply.github.com> Date: Fri, 12 Apr 2024 10:47:35 -0700 Subject: [PATCH] Make loadBalancer a readonly property (#117) Signed-off-by: Sayali Gaikawad --- lib/infra/infra-stack.ts | 14 ++++++++------ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/infra/infra-stack.ts b/lib/infra/infra-stack.ts index fb163872250..ba0c0b82df3 100644 --- a/lib/infra/infra-stack.ts +++ b/lib/infra/infra-stack.ts @@ -136,6 +136,8 @@ export interface InfraProps extends StackProps { } export class InfraStack extends Stack { + public readonly nlb: NetworkLoadBalancer; + private instanceRole: Role; private distVersion: string; @@ -396,7 +398,7 @@ export class InfraStack extends Stack { const certificateArn = `${props?.certificateArn ?? scope.node.tryGetContext('certificateArn')}`; - const nlb = new NetworkLoadBalancer(this, 'clusterNlb', { + this.nlb = new NetworkLoadBalancer(this, 'clusterNlb', { vpc: props.vpc, internetFacing: (!this.isInternal), crossZoneEnabled: true, @@ -427,13 +429,13 @@ export class InfraStack extends Stack { } if (!this.securityDisabled && !this.minDistribution && this.opensearchPortMapping === 443 && certificateArn !== 'undefined') { - opensearchListener = nlb.addListener('opensearch', { + opensearchListener = this.nlb.addListener('opensearch', { port: this.opensearchPortMapping, protocol: Protocol.TLS, certificates: [ListenerCertificate.fromArn(certificateArn)], }); } else { - opensearchListener = nlb.addListener('opensearch', { + opensearchListener = this.nlb.addListener('opensearch', { port: this.opensearchPortMapping, protocol: Protocol.TCP, }); @@ -441,13 +443,13 @@ export class InfraStack extends Stack { if (this.dashboardsUrl !== 'undefined') { if (!this.securityDisabled && !this.minDistribution && this.opensearchDashboardsPortMapping === 443 && certificateArn !== 'undefined') { - dashboardsListener = nlb.addListener('dashboards', { + dashboardsListener = this.nlb.addListener('dashboards', { port: this.opensearchDashboardsPortMapping, protocol: Protocol.TLS, certificates: [ListenerCertificate.fromArn(certificateArn)], }); } else { - dashboardsListener = nlb.addListener('dashboards', { + dashboardsListener = this.nlb.addListener('dashboards', { port: this.opensearchDashboardsPortMapping, protocol: Protocol.TCP, }); @@ -678,7 +680,7 @@ export class InfraStack extends Stack { } } new CfnOutput(this, 'loadbalancer-url', { - value: nlb.loadBalancerDnsName, + value: this.nlb.loadBalancerDnsName, }); if (this.enableMonitoring) { diff --git a/package-lock.json b/package-lock.json index 49887a6788e..37fc87c0dc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@opensearch-project/opensearch-cluster-cdk", - "version": "1.2.2", + "version": "1.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@opensearch-project/opensearch-cluster-cdk", - "version": "1.2.2", + "version": "1.2.3", "dependencies": { "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", diff --git a/package.json b/package.json index 7cc2704b6e9..21635df662c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@opensearch-project/opensearch-cluster-cdk", - "version": "1.2.2", + "version": "1.2.3", "bin": { "cdk_v2": "bin/app.js" },