For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-aws-eks-node-group-remote-access-disabled.md.
A documentation index is available at /llms.txt.
This check ensures that when configuring remote access for an AWS EKS node group, the source_security_group_ids attribute is specified. If this parameter is omitted, the EC2 instances in the EKS node group can potentially be accessed via SSH from any IP address, which significantly increases the risk of unauthorized access. By not restricting SSH access to a specific set of trusted security groups, the node group becomes more vulnerable to brute force attacks and other security threats. Properly configuring the source_security_group_ids limits remote access to only those network sources that are explicitly permitted, thereby reducing the node group’s attack surface.
Compliant Code Examples
resource"aws_eks_node_group""negative"{cluster_name=aws_eks_cluster.example.namenode_group_name="example"node_role_arn=aws_iam_role.example.arnsubnet_ids=aws_subnet.example[*].idscaling_config{desired_size=1max_size=1min_size=1}remote_access{ec2_ssh_key="my-rsa-key"source_security_groups_ids="sg-213120ASNE"} # Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
# Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
depends_on=[aws_iam_role_policy_attachment.example-AmazonEKSWorkerNodePolicy,aws_iam_role_policy_attachment.example-AmazonEKS_CNI_Policy,aws_iam_role_policy_attachment.example-AmazonEC2ContainerRegistryReadOnly,]}
Non-Compliant Code Examples
resource"aws_eks_node_group""positive"{cluster_name=aws_eks_cluster.example.namenode_group_name="example"node_role_arn=aws_iam_role.example.arnsubnet_ids=aws_subnet.example[*].idscaling_config{desired_size=1max_size=1min_size=1}remote_access{ec2_ssh_key="my-rsa-key"} # Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
# Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
depends_on=[aws_iam_role_policy_attachment.example-AmazonEKSWorkerNodePolicy,aws_iam_role_policy_attachment.example-AmazonEKS_CNI_Policy,aws_iam_role_policy_attachment.example-AmazonEC2ContainerRegistryReadOnly,]}
1
2
rulesets:- Terraform / AWS # Rules to enforce / AWS.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.