For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-eks-node-group-remote-access.md.
A documentation index is available at /llms.txt.
Amazon EKS node groups that configure an EC2 SSH key permit SSH access to worker nodes. If that access is not limited to specific security groups, it can be reachable from untrusted networks, enabling unauthorized access and lateral movement.
For AWS::EKS::Nodegroup resources, when Properties.RemoteAccess.Ec2SshKey is set, Properties.RemoteAccess.SourceSecurityGroups must be defined and not null to explicitly restrict SSH ingress to trusted security groups. Resources missing RemoteAccess.SourceSecurityGroups or with it set to null will be flagged.
Resources:SSHAccessToNodeSG:Type:AWS::EC2::SecurityGroupProperties:VpcId:!Ref VpcIdGroupName:!Sub "${Project}-${Environment}-${EKSClusterName}-ssh-access-to-workers-source-sg"GroupDescription:attach this sg to an instance to let it access via ssh to the eks nodeTags:- Key:EnvironmentValue:!Ref Environment- Key:ProjectValue:!Ref ProjectEKSNodegroup:Type:'AWS::EKS::Nodegroup'Properties:ClusterName:prodNodeRole:'arn:aws:iam::012345678910:role/eksInstanceRole'ScalingConfig:MinSize:3DesiredSize:5MaxSize:7Labels:Key1:Value1Key2:Value2Subnets:- subnet-6782e71e- subnet-e7e761acRemoteAccess:Ec2SshKey:ED25519SourceSecurityGroups:- !Ref SSHAccessToNodeSG
{"Resources":{"SSHAccessToNodeSG":{"Type":"AWS::EC2::SecurityGroup","Properties":{"VpcId":"VpcId","GroupName":"${Project}-${Environment}-${EKSClusterName}-ssh-access-to-workers-source-sg","GroupDescription":"attach this sg to an instance to let it access via ssh to the eks node","Tags":[{"Key":"Environment","Value":"Environment"},{"Key":"Project","Value":"Project"}]}},"EKSNodegroup":{"Properties":{"RemoteAccess":{"Ec2SshKey":"ED25519","SourceSecurityGroups":["SSHAccessToNodeSG"]},"ClusterName":"prod","NodeRole":"arn:aws:iam::012345678910:role/eksInstanceRole","ScalingConfig":{"MinSize":3,"DesiredSize":5,"MaxSize":7},"Labels":{"Key1":"Value1","Key2":"Value2"},"Subnets":["subnet-6782e71e","subnet-e7e761ac"]},"Type":"AWS::EKS::Nodegroup"}}}