Skip to content

Commit ef8ab72

Browse files
authored
fix(eks): the defaultChild of a KubernetesManifest is not a CfnResource (#18052)
The type of `node.defaultChild` is `KubernetesManifest` and not a `CfnResource`, preventing users from using escape hatches in the standard way. Fixes #9921. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2b6c2da commit ef8ab72

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/@aws-cdk/aws-eks/lib/k8s-manifest.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class KubernetesManifest extends CoreConstruct {
139139
this.injectIngressAlbAnnotations(props.manifest, props.ingressAlbScheme ?? AlbScheme.INTERNAL);
140140
}
141141

142-
new CustomResource(this, 'Resource', {
142+
const customResource = new CustomResource(this, 'Resource', {
143143
serviceToken: provider.serviceToken,
144144
resourceType: KubernetesManifest.RESOURCE_TYPE,
145145
properties: {
@@ -154,6 +154,8 @@ export class KubernetesManifest extends CoreConstruct {
154154
SkipValidation: props.skipValidation,
155155
},
156156
});
157+
158+
this.node.defaultChild = customResource.node.defaultChild;
157159
}
158160

159161
/**

packages/@aws-cdk/aws-eks/test/k8s-manifest.test.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '@aws-cdk/assert-internal/jest';
22
import { SynthUtils } from '@aws-cdk/assert-internal';
3-
import { Stack } from '@aws-cdk/core';
3+
import { CfnResource, Stack } from '@aws-cdk/core';
44
import { Cluster, KubernetesManifest, KubernetesVersion, HelmChart } from '../lib';
55
import { testFixtureNoVpc, testFixtureCluster } from './util';
66

@@ -109,6 +109,17 @@ describe('k8s manifest', () => {
109109

110110
});
111111

112+
test('default child is a CfnResource', () => {
113+
const stack = new Stack();
114+
const cluster = Cluster.fromClusterAttributes(stack, 'MyCluster', {
115+
clusterName: 'my-cluster-name',
116+
kubectlRoleArn: 'arn:aws:iam::1111111:role/iam-role-that-has-masters-access',
117+
});
118+
119+
const manifest = cluster.addManifest('foo', { bar: 2334 });
120+
expect(manifest.node.defaultChild).toBeInstanceOf(CfnResource);
121+
});
122+
112123
describe('prune labels', () => {
113124

114125
test('base case', () => {

0 commit comments

Comments
 (0)