Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check failure on line 1 in packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-windows-ng.js.snapshot/aws-cdk-eks-cluster-windows-ng-test.template.json

View workflow job for this annotation

GitHub Actions / Security Guardian Results with resolved templates

iam-role-root-principal-needs-conditions.guard

IAM_ROLE_ROOT_PRINCIPAL_NEEDS_CONDITIONS for Type: Resolved
Raw output
Root principal requires a strict condition (ArnEquals or StringEquals) to scope down who can assume this role. ArnLike/StringLike are not accepted as they allow wildcards.
Check was not compliant as property [Condition] is missing. Value traversed to [Path=/Resources/AdminRole38563C57/Properties/AssumeRolePolicyDocument/Statement/0[L:8,C:12] Value={"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:root"}}].
Check was not compliant as property [Condition.ArnEquals] is missing. Value traversed to [Path=/Resources/AdminRole38563C57/Properties/AssumeRolePolicyDocument/Statement/0[L:8,C:12] Value={"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:root"}}].
Check was not compliant as property [Condition.StringEquals] is missing. Value traversed to [Path=/Resources/AdminRole38563C57/Properties/AssumeRolePolicyDocument/Statement/0[L:8,C:12] Value={"Action":"sts:AssumeRole","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:root"}}].
"Resources": {
"AdminRole38563C57": {
"Type": "AWS::IAM::Role",
Expand Down Expand Up @@ -882,7 +882,7 @@
"Arn"
]
},
"\\\",\\\"username\\\":\\\"system:node:{{EC2PrivateDNSName}}\\\",\\\"groups\\\":[\\\"system:bootstrappers\\\",\\\"system:nodes\\\"]}]\",\"mapUsers\":\"[]\",\"mapAccounts\":\"[]\"}}]"
"\\\",\\\"username\\\":\\\"system:node:{{EC2PrivateDNSName}}\\\",\\\"groups\\\":[\\\"system:bootstrappers\\\",\\\"system:nodes\\\",\\\"eks:kube-proxy-windows\\\"]}]\",\"mapUsers\":\"[]\",\"mapAccounts\":\"[]\"}}]"
]
]
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,16 @@ export class Nodegroup extends Resource implements INodegroup {
// only when ConfigMap is supported
const supportConfigMap = props.cluster.authenticationMode !== AuthenticationMode.API ? true : false;
if (supportConfigMap) {
const groups = [
'system:bootstrappers',
'system:nodes',
];
if (props.amiType && windowsAmiTypes.includes(props.amiType)) {
groups.push('eks:kube-proxy-windows');
}
this.cluster.awsAuth.addRoleMapping(this.role, {
username: 'system:node:{{EC2PrivateDNSName}}',
groups: [
'system:bootstrappers',
'system:nodes',
],
groups,
});
}
// the controller runs on the worker nodes so they cannot
Expand Down
26 changes: 26 additions & 0 deletions packages/aws-cdk-lib/aws-eks/test/nodegroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1899,3 +1899,29 @@ describe('isGpuInstanceType', () => {
});
});
});

test('Windows node group includes eks:kube-proxy-windows group in aws-auth', () => {
// GIVEN
const { stack } = testFixture();
const cluster = new eks.Cluster(stack, 'Cluster', {
defaultCapacity: 0,
version: CLUSTER_VERSION,
kubectlLayer: new KubectlV31Layer(stack, 'KubectlLayer'),
});

// WHEN
new eks.Nodegroup(stack, 'Nodegroup', {
cluster,
amiType: NodegroupAmiType.WINDOWS_CORE_2022_X86_64,
});

// THEN - the aws-auth ConfigMap should contain eks:kube-proxy-windows group
const template = Template.fromStack(stack);
const manifest = template.findResources('Custom::AWSCDK-EKS-KubernetesResource');
const manifestValues = Object.values(manifest);
const awsAuthManifest = manifestValues.find((m: any) =>
JSON.stringify(m.Properties?.Manifest ?? '').includes('aws-auth'),
);
expect(awsAuthManifest).toBeDefined();
expect(JSON.stringify(awsAuthManifest)).toContain('eks:kube-proxy-windows');
});
Loading