diff --git a/packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/handler.ts b/packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/handler.ts index 5db46ab5bd344..fffecc40445cf 100644 --- a/packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/handler.ts +++ b/packages/@aws-cdk/aws-eks/lib/cluster-resource-handler/handler.ts @@ -4,6 +4,8 @@ import { IsCompleteResponse, OnEventResponse } from '@aws-cdk/custom-resources/l // eslint-disable-next-line import/no-extraneous-dependencies import * as aws from 'aws-sdk'; +const MAX_CLUSTER_NAME_LEN = 100; + export class ClusterResourceHandler { public get clusterName() { @@ -71,7 +73,7 @@ export class ClusterResourceHandler { throw new Error('"roleArn" is required'); } - const clusterName = this.newProps.name || `${this.logicalResourceId}-${this.requestId}`; + const clusterName = this.newProps.name || this.generateClusterName(); const resp = await this.eks.createCluster({ ...this.newProps, @@ -221,6 +223,12 @@ export class ClusterResourceHandler { }; } } + + private generateClusterName() { + const suffix = this.requestId.replace(/-/g, ''); // 32 chars + const prefix = this.logicalResourceId.substr(0, MAX_CLUSTER_NAME_LEN - suffix.length - 1); + return `${prefix}-${suffix}`; + } } export interface EksClient { diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.defaults.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.defaults.expected.json index 884d24d0bafe4..bd90e0c868cc5 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.defaults.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.defaults.expected.json @@ -1145,7 +1145,7 @@ }, "/", { - "Ref": "AssetParameters209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55S3Bucket67889A58" + "Ref": "AssetParametersf29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfeS3Bucket39A5D284" }, "/", { @@ -1155,7 +1155,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55S3VersionKey4A356825" + "Ref": "AssetParametersf29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfeS3VersionKey9DC7495B" } ] } @@ -1168,7 +1168,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55S3VersionKey4A356825" + "Ref": "AssetParametersf29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfeS3VersionKey9DC7495B" } ] } @@ -1178,11 +1178,11 @@ ] }, "Parameters": { - "referencetoeksintegdefaults2AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3Bucket61EFA364Ref": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468" + "referencetoeksintegdefaults2AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3BucketA564E391Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6" }, - "referencetoeksintegdefaults2AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKey99475258Ref": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4" + "referencetoeksintegdefaults2AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey1BE9ECA3Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577" }, "referencetoeksintegdefaults2AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3Bucket45B8FC93Ref": { "Ref": "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE" @@ -1315,17 +1315,17 @@ } }, "Parameters": { - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6": { "Type": "String", - "Description": "S3 bucket for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 bucket for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577": { "Type": "String", - "Description": "S3 key for asset version \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 key for asset version \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cArtifactHash1871DA56": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaArtifactHashC8E461E7": { "Type": "String", - "Description": "Artifact hash for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "Artifact hash for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE": { "Type": "String", @@ -1363,17 +1363,17 @@ "Type": "String", "Description": "Artifact hash for asset \"9c326f06202274fde286cdfb04b4d8be6f58ef01451f732630a5fb719e047b17\"" }, - "AssetParameters209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55S3Bucket67889A58": { + "AssetParametersf29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfeS3Bucket39A5D284": { "Type": "String", - "Description": "S3 bucket for asset \"209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55\"" + "Description": "S3 bucket for asset \"f29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfe\"" }, - "AssetParameters209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55S3VersionKey4A356825": { + "AssetParametersf29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfeS3VersionKey9DC7495B": { "Type": "String", - "Description": "S3 key for asset version \"209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55\"" + "Description": "S3 key for asset version \"f29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfe\"" }, - "AssetParameters209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55ArtifactHashB9F5917F": { + "AssetParametersf29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfeArtifactHashF9EE70CA": { "Type": "String", - "Description": "Artifact hash for asset \"209b080b138756cffeb08c815ba4ccfc21ca95800e8cd2bd26c0e5ea0a4fbb55\"" + "Description": "Artifact hash for asset \"f29b7dd5a7cb088f618b2e9719b79ce3a4c26d5def29508494ba139f87bdddfe\"" }, "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.lit.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.lit.expected.json index b064204bf80bd..f7770866c8ac9 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.lit.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-cluster.lit.expected.json @@ -1145,7 +1145,7 @@ }, "/", { - "Ref": "AssetParameters0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aaS3Bucket8A1FC920" + "Ref": "AssetParametersdf3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293S3BucketF5EA9203" }, "/", { @@ -1155,7 +1155,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aaS3VersionKeyA377CBC7" + "Ref": "AssetParametersdf3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293S3VersionKeyBDC1E9A0" } ] } @@ -1168,7 +1168,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aaS3VersionKeyA377CBC7" + "Ref": "AssetParametersdf3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293S3VersionKeyBDC1E9A0" } ] } @@ -1178,11 +1178,11 @@ ] }, "Parameters": { - "referencetoeksintegtestbasicAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketACC4B323Ref": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468" + "referencetoeksintegtestbasicAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket323156A5Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6" }, - "referencetoeksintegtestbasicAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKey84768DF0Ref": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4" + "referencetoeksintegtestbasicAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey8C792C48Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577" }, "referencetoeksintegtestbasicAssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE44A33FBRef": { "Ref": "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE" @@ -1286,17 +1286,17 @@ } }, "Parameters": { - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6": { "Type": "String", - "Description": "S3 bucket for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 bucket for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577": { "Type": "String", - "Description": "S3 key for asset version \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 key for asset version \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cArtifactHash1871DA56": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaArtifactHashC8E461E7": { "Type": "String", - "Description": "Artifact hash for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "Artifact hash for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE": { "Type": "String", @@ -1334,17 +1334,17 @@ "Type": "String", "Description": "Artifact hash for asset \"9356e02536cba133d17d8dc3b3b37541377d2e95d4d33433ea90e79ab0d859fe\"" }, - "AssetParameters0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aaS3Bucket8A1FC920": { + "AssetParametersdf3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293S3BucketF5EA9203": { "Type": "String", - "Description": "S3 bucket for asset \"0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aa\"" + "Description": "S3 bucket for asset \"df3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293\"" }, - "AssetParameters0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aaS3VersionKeyA377CBC7": { + "AssetParametersdf3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293S3VersionKeyBDC1E9A0": { "Type": "String", - "Description": "S3 key for asset version \"0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aa\"" + "Description": "S3 key for asset version \"df3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293\"" }, - "AssetParameters0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aaArtifactHash01378DA1": { + "AssetParametersdf3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293ArtifactHashB12A2009": { "Type": "String", - "Description": "Artifact hash for asset \"0dbfc75e2973c6dc284120b2ea80dd6df7c704e57ed3d90672ee28131aef83aa\"" + "Description": "Artifact hash for asset \"df3b5d90d7dad88d62bd14f50797dac8969e0ada6fb00c19af4019edf4c3a293\"" }, "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-helm.lit.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-helm.lit.expected.json index d4894f4049fb1..fe1bc2954cf73 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-helm.lit.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-helm.lit.expected.json @@ -1071,7 +1071,7 @@ }, "/", { - "Ref": "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3BucketB74693EC" + "Ref": "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3Bucket6C6C9359" }, "/", { @@ -1081,7 +1081,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3VersionKeyDD3D4940" + "Ref": "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3VersionKeyD9E934ED" } ] } @@ -1094,7 +1094,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3VersionKeyDD3D4940" + "Ref": "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3VersionKeyD9E934ED" } ] } @@ -1104,11 +1104,11 @@ ] }, "Parameters": { - "referencetok8sclusterAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3Bucket40DAFEBFRef": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468" + "referencetok8sclusterAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3BucketC7043C91Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6" }, - "referencetok8sclusterAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyD9847EBDRef": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4" + "referencetok8sclusterAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey016E0262Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577" }, "referencetok8sclusterAssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3Bucket6EE66685Ref": { "Ref": "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE" @@ -1301,17 +1301,17 @@ } }, "Parameters": { - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6": { "Type": "String", - "Description": "S3 bucket for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 bucket for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577": { "Type": "String", - "Description": "S3 key for asset version \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 key for asset version \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cArtifactHash1871DA56": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaArtifactHashC8E461E7": { "Type": "String", - "Description": "Artifact hash for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "Artifact hash for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE": { "Type": "String", @@ -1373,17 +1373,17 @@ "Type": "String", "Description": "Artifact hash for asset \"8ca585e0c579a7f28f17f90e8e3e462c4cfeac06aa452dc164cb8200e5a40dec\"" }, - "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3BucketB74693EC": { + "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3Bucket6C6C9359": { "Type": "String", - "Description": "S3 bucket for asset \"6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eae\"" + "Description": "S3 bucket for asset \"287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657de\"" }, - "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3VersionKeyDD3D4940": { + "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3VersionKeyD9E934ED": { "Type": "String", - "Description": "S3 key for asset version \"6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eae\"" + "Description": "S3 key for asset version \"287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657de\"" }, - "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeArtifactHashE7AA97DD": { + "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deArtifactHash79A56F45": { "Type": "String", - "Description": "Artifact hash for asset \"6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eae\"" + "Description": "Artifact hash for asset \"287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657de\"" }, "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-kubectl.lit.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-kubectl.lit.expected.json index c490d41a5c4c2..d248a71094ca6 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-kubectl.lit.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-kubectl.lit.expected.json @@ -1030,7 +1030,7 @@ }, "/", { - "Ref": "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3BucketB74693EC" + "Ref": "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3Bucket6C6C9359" }, "/", { @@ -1040,7 +1040,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3VersionKeyDD3D4940" + "Ref": "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3VersionKeyD9E934ED" } ] } @@ -1053,7 +1053,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3VersionKeyDD3D4940" + "Ref": "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3VersionKeyD9E934ED" } ] } @@ -1063,11 +1063,11 @@ ] }, "Parameters": { - "referencetok8sclusterAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3Bucket40DAFEBFRef": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468" + "referencetok8sclusterAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3BucketC7043C91Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6" }, - "referencetok8sclusterAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyD9847EBDRef": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4" + "referencetok8sclusterAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey016E0262Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577" }, "referencetok8sclusterAssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3Bucket6EE66685Ref": { "Ref": "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE" @@ -1199,17 +1199,17 @@ } }, "Parameters": { - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6": { "Type": "String", - "Description": "S3 bucket for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 bucket for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577": { "Type": "String", - "Description": "S3 key for asset version \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 key for asset version \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cArtifactHash1871DA56": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaArtifactHashC8E461E7": { "Type": "String", - "Description": "Artifact hash for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "Artifact hash for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE": { "Type": "String", @@ -1247,17 +1247,17 @@ "Type": "String", "Description": "Artifact hash for asset \"8ca585e0c579a7f28f17f90e8e3e462c4cfeac06aa452dc164cb8200e5a40dec\"" }, - "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3BucketB74693EC": { + "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3Bucket6C6C9359": { "Type": "String", - "Description": "S3 bucket for asset \"6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eae\"" + "Description": "S3 bucket for asset \"287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657de\"" }, - "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeS3VersionKeyDD3D4940": { + "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deS3VersionKeyD9E934ED": { "Type": "String", - "Description": "S3 key for asset version \"6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eae\"" + "Description": "S3 key for asset version \"287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657de\"" }, - "AssetParameters6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eaeArtifactHashE7AA97DD": { + "AssetParameters287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657deArtifactHash79A56F45": { "Type": "String", - "Description": "Artifact hash for asset \"6d5f4417369ef3ef78dab6f6deae64529815a2be8d25a7d6161999af0bfe9eae\"" + "Description": "Artifact hash for asset \"287294bfd74c989676c1bf6e34b8dfdb020cb1458d28eda2b603bd7362c657de\"" }, "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-eks/test/integ.eks-spot.expected.json b/packages/@aws-cdk/aws-eks/test/integ.eks-spot.expected.json index 09dba021cfe11..b270b6aab3f92 100644 --- a/packages/@aws-cdk/aws-eks/test/integ.eks-spot.expected.json +++ b/packages/@aws-cdk/aws-eks/test/integ.eks-spot.expected.json @@ -1290,7 +1290,7 @@ }, "/", { - "Ref": "AssetParameters7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4S3Bucket6A27A3E1" + "Ref": "AssetParametersefa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10S3Bucket1BCC2DEE" }, "/", { @@ -1300,7 +1300,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4S3VersionKey37965366" + "Ref": "AssetParametersefa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10S3VersionKey19E7B26A" } ] } @@ -1313,7 +1313,7 @@ "Fn::Split": [ "||", { - "Ref": "AssetParameters7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4S3VersionKey37965366" + "Ref": "AssetParametersefa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10S3VersionKey19E7B26A" } ] } @@ -1323,11 +1323,11 @@ ] }, "Parameters": { - "referencetointegeksspotAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3Bucket6C030246Ref": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468" + "referencetointegeksspotAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket4C57DF8FRef": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6" }, - "referencetointegeksspotAssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyA27A439ARef": { - "Ref": "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4" + "referencetointegeksspotAssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey2C860862Ref": { + "Ref": "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577" }, "referencetointegeksspotAssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3Bucket44C2F8EBRef": { "Ref": "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE" @@ -1431,17 +1431,17 @@ } }, "Parameters": { - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3BucketE861A468": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3Bucket8E07DCB6": { "Type": "String", - "Description": "S3 bucket for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 bucket for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cS3VersionKeyB62DD0C4": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaS3VersionKey0B557577": { "Type": "String", - "Description": "S3 key for asset version \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "S3 key for asset version \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, - "AssetParameterse3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7cArtifactHash1871DA56": { + "AssetParametersf9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692eaArtifactHashC8E461E7": { "Type": "String", - "Description": "Artifact hash for asset \"e3e075ac49ed41df2d65a2461111e2462dae18db8ec082455daea8dab8d47b7c\"" + "Description": "Artifact hash for asset \"f9dcd200023059b31d92ba9ecdd46ce324d5fada466a683b42b425a5bd1692ea\"" }, "AssetParameters3e728f777afd6d4a580bc77d99f86194358dca730432b3f4583e544f1e85d2a0S3BucketE8BB46CE": { "Type": "String", @@ -1479,17 +1479,17 @@ "Type": "String", "Description": "Artifact hash for asset \"e31578e5879b0e1834f6dd91c6b5fa5d2bfc07e3932f8d3ff3d7c476123ae005\"" }, - "AssetParameters7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4S3Bucket6A27A3E1": { + "AssetParametersefa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10S3Bucket1BCC2DEE": { "Type": "String", - "Description": "S3 bucket for asset \"7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4\"" + "Description": "S3 bucket for asset \"efa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10\"" }, - "AssetParameters7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4S3VersionKey37965366": { + "AssetParametersefa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10S3VersionKey19E7B26A": { "Type": "String", - "Description": "S3 key for asset version \"7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4\"" + "Description": "S3 key for asset version \"efa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10\"" }, - "AssetParameters7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4ArtifactHashED1E024F": { + "AssetParametersefa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10ArtifactHash54DDB96B": { "Type": "String", - "Description": "Artifact hash for asset \"7ad0795676184a4f55098809e8bc18c4253e36cd3c181295c2e43ad3eaf89ce4\"" + "Description": "Artifact hash for asset \"efa0ed11047abec234acb0144b4fea6ec7143d761be333903712d46e4b185e10\"" }, "SsmParameterValueawsserviceeksoptimizedami114amazonlinux2recommendedimageidC96584B6F00A464EAD1953AFF4B05118Parameter": { "Type": "AWS::SSM::Parameter::Value", diff --git a/packages/@aws-cdk/aws-eks/test/test.cluster-resource-provider.ts b/packages/@aws-cdk/aws-eks/test/test.cluster-resource-provider.ts index a852a40a30166..b0ef85d635c92 100644 --- a/packages/@aws-cdk/aws-eks/test/test.cluster-resource-provider.ts +++ b/packages/@aws-cdk/aws-eks/test/test.cluster-resource-provider.ts @@ -24,12 +24,40 @@ export = { subnetIds: ['subnet1', 'subnet2'], securityGroupIds: ['sg1', 'sg2', 'sg3'] }, - name: 'MyResourceId-fake-request-id' + name: 'MyResourceId-fakerequestid' }); test.done(); }, + async 'generated cluster name does not exceed 100 characters'(test: Test) { + // GIVEN + const req = { + StackId: 'fake-stack-id', + RequestId: '602c078a-6181-4352-9676-4f00352445aa', + ResourceType: 'Custom::EKSCluster', + ServiceToken: 'boom', + LogicalResourceId: 'hello'.repeat(30), // 150 chars (limit is 100) + PhysicalResourceId: 'physical-resource-id', + ResponseURL: 'http://response-url', + RequestType: 'Create', + ResourceProperties: { + ServiceToken: 'boom', + Config: mocks.MOCK_PROPS, + AssumeRoleArn: mocks.MOCK_ASSUME_ROLE_ARN + } + }; + + // WHEN + const handler = new ClusterResourceHandler(mocks.client, req); + await handler.onEvent(); + + // THEN + test.equal(mocks.actualRequest.createClusterRequest?.name.length, 100); + test.deepEqual(mocks.actualRequest.createClusterRequest?.name, 'hellohellohellohellohellohellohellohellohellohellohellohellohellohe-602c078a6181435296764f00352445aa'); + test.done(); + }, + async 'onCreate: explicit cluster name'(test: Test) { const handler = new ClusterResourceHandler(mocks.client, mocks.newRequest('Create', { ...mocks.MOCK_PROPS, @@ -200,7 +228,7 @@ export = { // THEN test.deepEqual(mocks.actualRequest.createClusterRequest!, { - name: 'MyResourceId-fake-request-id', + name: 'MyResourceId-fakerequestid', roleArn: 'arn:of:role', resourcesVpcConfig: { @@ -208,7 +236,7 @@ export = { securityGroupIds: ['sg1', 'sg2', 'sg3'] } }); - test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fake-request-id' }); + test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fakerequestid' }); test.done(); }, @@ -230,9 +258,9 @@ export = { })); const resp = await handler.onEvent(); - test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fake-request-id' }); + test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fakerequestid' }); test.deepEqual(mocks.actualRequest.createClusterRequest, { - name: 'MyResourceId-fake-request-id', + name: 'MyResourceId-fakerequestid', roleArn: 'arn:of:role', resourcesVpcConfig: { @@ -251,9 +279,9 @@ export = { })); const resp = await handler.onEvent(); - test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fake-request-id' }); + test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fakerequestid' }); test.deepEqual(mocks.actualRequest.createClusterRequest, { - name: 'MyResourceId-fake-request-id', + name: 'MyResourceId-fakerequestid', roleArn: 'new-arn' }); test.done(); @@ -295,9 +323,9 @@ export = { const resp = await handler.onEvent(); // THEN - test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fake-request-id' }); + test.deepEqual(resp, { PhysicalResourceId: 'MyResourceId-fakerequestid' }); test.deepEqual(mocks.actualRequest.createClusterRequest, { - name: 'MyResourceId-fake-request-id', + name: 'MyResourceId-fakerequestid', roleArn: 'new-arn' }); test.done();