diff --git a/lib/addons/core-addon/index.ts b/lib/addons/core-addon/index.ts index 4a080eb5c..60312ed69 100644 --- a/lib/addons/core-addon/index.ts +++ b/lib/addons/core-addon/index.ts @@ -7,6 +7,7 @@ import { KubernetesVersion } from "aws-cdk-lib/aws-eks"; import { createServiceAccountWithPolicy, deployBeforeCapacity, logger, userLog, } from "../../utils"; import * as sdk from "@aws-sdk/client-eks"; import { RemovalPolicy } from "aws-cdk-lib"; +import cluster from "cluster"; export class CoreAddOnProps { /** @@ -87,7 +88,7 @@ export class CoreAddOn implements ClusterAddOn { let version: string = this.coreAddOnProps.version; if (this.coreAddOnProps.version === "auto") { - version = await this.provideVersion(clusterInfo); + version = await this.provideVersion(clusterInfo.version, clusterInfo.cluster.stack.region); } let addOnProps = { @@ -176,11 +177,11 @@ export class CoreAddOn implements ClusterAddOn { return result; } - async provideVersion(clusterInfo: ClusterInfo) : Promise { - const client = new sdk.EKSClient({ region: clusterInfo.cluster.stack.region }); + async provideVersion(clusterVersion: KubernetesVersion, region: string) : Promise { + const client = new sdk.EKSClient({ region }); const command = new sdk.DescribeAddonVersionsCommand({ addonName: this.coreAddOnProps.addOnName, - kubernetesVersion: clusterInfo.version.version + kubernetesVersion: clusterVersion.version }); try { @@ -210,7 +211,7 @@ export class CoreAddOn implements ClusterAddOn { logger.warn(`Failed to retrieve add-on versions from EKS for add-on ${this.coreAddOnProps.addOnName}.`); logger.warn("Possible reasons for failures - Unauthorized or Authentication failure or Network failure on the terminal."); logger.warn(" Falling back to default version."); - let version: string = this.provideDefaultAutoVersion(clusterInfo.version); + let version: string = this.provideDefaultAutoVersion(clusterVersion); userLog.debug(`Core add-on ${this.coreAddOnProps.addOnName} has autoselected version ${version}`); return version; } diff --git a/package.json b/package.json index 76a2ba630..d5ba2d74e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aws-quickstart/eks-blueprints", - "version": "1.16.1", + "version": "1.16.2", "license": "Apache-2.0", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/test/cloudwatch-insights.test.ts b/test/cloudwatch-insights.test.ts index 0303c7e33..d28405eff 100644 --- a/test/cloudwatch-insights.test.ts +++ b/test/cloudwatch-insights.test.ts @@ -80,7 +80,7 @@ describe('Unit test for CloudWatch Addon', () => { const app = new cdk.App(); const addOn = new blueprints.CloudWatchInsights({}); - const version = KubernetesVersion.V1_29; + const version = KubernetesVersion.V1_30; const blueprint = await blueprints.EksBlueprint.builder() .version(version) .account("123456789012").region('us-east-2') @@ -89,9 +89,11 @@ describe('Unit test for CloudWatch Addon', () => { const template = Template.fromStack(blueprint); + const inferredVersion = await addOn.provideVersion(version, 'us-west-2'); + template.hasResource("AWS::EKS::Addon", { Properties: { - "AddonVersion": Match.exact(addOn.provideDefaultAutoVersion(version)) + "AddonVersion": Match.exact(inferredVersion) } }); });