Skip to content

Commit e104f45

Browse files
authored
fix(eks-v2-alpha): ensure kubectl provider access entry is depended upon by downstream resources (#36734)
_Note: Copied from #34898 with updated snapshots, credit to @msessa._ Closes #34897 ### Reason for this change The `AccessEntry` for kubectl provider should be included as a dependency of the kubectl ready barrier. ### Description of changes Add the kubectl `AccessEntry` to the explicit dependencies for the ready barrier resource ### Description of how you validated changes - Updated unit test - Updated integration tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5137d81 commit e104f45

277 files changed

Lines changed: 8557 additions & 8438 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/@aws-cdk/aws-eks-v2-alpha/lib/cluster.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,9 @@ export class Cluster extends ClusterBase {
12961296
// give the handler role admin access to the cluster
12971297
// so it can deploy/query any resource.
12981298
this._clusterAdminAccess = this.grantClusterAdmin('ClusterAdminRoleAccess', this._kubectlProvider?.role!.roleArn);
1299+
1300+
// Ensure kubectl is marked as ready only after admin access has been granted
1301+
this._kubectlReadyBarrier.node.addDependency(this._clusterAdminAccess);
12991302
}
13001303

13011304
// do not create a masters role if one is not provided. Trusting the accountRootPrincipal() is too permissive.

packages/@aws-cdk/aws-eks-v2-alpha/test/cluster.test.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,25 +1552,43 @@ describe('cluster', () => {
15521552
// THEN
15531553
const template = app.synth().getStackArtifact(stack.artifactId).template;
15541554

1555-
const barrier = template.Resources.ClusterKubectlReadyBarrier200052AF;
1556-
1557-
expect(barrier.DependsOn).toEqual([
1558-
'Clusterfargateprofileprofile1PodExecutionRoleE85F87B5',
1559-
'Clusterfargateprofileprofile129AEA3C6',
1560-
'Clusterfargateprofileprofile2PodExecutionRole22670AF8',
1561-
'Clusterfargateprofileprofile233B9A117',
1562-
'Clusterfargateprofileprofile3PodExecutionRole475C0D8F',
1563-
'Clusterfargateprofileprofile3D06F3076',
1564-
'Clusterfargateprofileprofile4PodExecutionRole086057FB',
1565-
'Clusterfargateprofileprofile4A0E3BBE8',
1566-
'ClusterEB0386A7',
1567-
]);
1568-
1569-
const kubectlResources = ['chartF2447AFC', 'patch1B964AC93', 'Clustermanifestresource10B1C9505'];
1555+
const kubectlReadyBarrier = 'ClusterKubectlReadyBarrier200052AF';
1556+
const barrier = template.Resources[kubectlReadyBarrier];
1557+
1558+
const adminRoleAccess = 'ClusterClusterAdminRoleAccessF2BFF759';
1559+
const profile1PodExecutionRole = 'Clusterfargateprofileprofile1PodExecutionRoleE85F87B5';
1560+
const profile1 = 'Clusterfargateprofileprofile129AEA3C6';
1561+
const profile2PodExecutionRole = 'Clusterfargateprofileprofile2PodExecutionRole22670AF8';
1562+
const profile2 = 'Clusterfargateprofileprofile233B9A117';
1563+
const profile3PodExecutionRole = 'Clusterfargateprofileprofile3PodExecutionRole475C0D8F';
1564+
const profile3 = 'Clusterfargateprofileprofile3D06F3076';
1565+
const profile4PodExecutionRole = 'Clusterfargateprofileprofile4PodExecutionRole086057FB';
1566+
const profile4 = 'Clusterfargateprofileprofile4A0E3BBE8';
1567+
const clusterResource = 'ClusterEB0386A7';
1568+
1569+
const expectedBarrierDependencies = [
1570+
adminRoleAccess,
1571+
profile1PodExecutionRole,
1572+
profile1,
1573+
profile2PodExecutionRole,
1574+
profile2,
1575+
profile3PodExecutionRole,
1576+
profile3,
1577+
profile4PodExecutionRole,
1578+
profile4,
1579+
clusterResource,
1580+
];
1581+
1582+
expect(barrier.DependsOn).toEqual(expectedBarrierDependencies);
1583+
1584+
const helmChart = 'chartF2447AFC';
1585+
const kubernetesPatch = 'patch1B964AC93';
1586+
const kubernetesManifest = 'Clustermanifestresource10B1C9505';
1587+
const kubectlResources = [helmChart, kubernetesPatch, kubernetesManifest];
15701588

15711589
// check that all kubectl resources depend on the barrier
1572-
for (const r of kubectlResources) {
1573-
expect(template.Resources[r].DependsOn).toEqual(['ClusterKubectlReadyBarrier200052AF']);
1590+
for (const resource of kubectlResources) {
1591+
expect(template.Resources[resource].DependsOn).toEqual([kubectlReadyBarrier]);
15741592
}
15751593
});
15761594

packages/@aws-cdk/aws-eks-v2-alpha/test/integ.alb-controller.js.snapshot/asset.39472b1c2875cf306d4ba429aeccdd34cb49bcf59dbde81f7e6b6cb9deac23a6/cfn-response.js

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)