April 25, 2023
6
min

Common IAM Issues and Solutions for AWS EKS

When deploying workloads to EKS, it is important to ensure that appropriate access control is in place to protect resources and data. This is where IAM roles and policies come into play. IAM roles and policies in Amazon EKS are used to define and manage permissions for Kubernetes resources running in an EKS cluster. IAM roles are used to grant access to AWS resources and services, while Kubernetes policies are used to grant access to Kubernetes resources.
Tal Shladovsky
Cloud Specialist

TL;DR

AWS Elastic Kubernetes Service (EKS) can provide significant benefits in terms of scalability and flexibility, it also comes with its own set of challenges related to Identity and Access Management (IAM) that can have a significant impact on the overall security and stability of your clusters.

Knowing more about the following common IAM issues and how to solve them can help get more out of EKS: 

  • Access Denied Error
  • Invalid ARN Error
  • AWS Credentials Error
  • Role Mapping Error
  • IAM Policy Limitations Error

Overview

Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that makes it easy to run Kubernetes on AWS. When deploying workloads to EKS, it is important to ensure that appropriate access control is in place to protect resources and data. This is where IAM roles and policies come into play. IAM roles and policies in Amazon EKS are used to define and manage permissions for Kubernetes resources running in an EKS cluster. IAM roles are used to grant access to AWS resources and services, while Kubernetes policies are used to grant access to Kubernetes resources.

In EKS, IAM roles are associated with worker nodes, which are EC2 instances that are part of an EKS cluster. Each worker node is associated with an IAM role that defines the permissions that the node has to AWS resources and services. Kubernetes policies are used to grant access to Kubernetes resources, such as pods, services, and namespaces. Policies can be defined at the cluster level, or at the individual resource level. These policies can be used to control access to sensitive resources, limit the actions that can be performed on resources, and ensure that only authorized users and applications have access to resources.

Importance of troubleshooting IAM issues

As mentioned earlier, IAM roles and policies in Amazon EKS are critical for controlling access to resources and ensuring the security of the EKS cluster. However, misconfigurations and errors in IAM roles and policies can lead to access issues, which can cause disruptions in the application and affect the availability of the cluster. Therefore, troubleshooting IAM issues is important to ensure that the EKS cluster is running smoothly and securely.  
Some common IAM issues that may require troubleshooting include:

  1. Incorrect permissions: IAM policies may not have the required permissions to access certain resources, which can result in authentication failures or access denied errors.
  1. Incorrect roles: If worker nodes are associated with incorrect IAM roles, they may not have the required permissions to perform certain tasks, which can lead to failures or errors.
  1. Resource conflicts: If multiple IAM policies are conflicting with each other, it can cause access issues and disrupt the functioning of the EKS cluster.
  1. Misconfiguration: Incorrectly configured IAM roles and policies can cause unexpected behavior and may result in access issues.

To troubleshoot IAM issues in Amazon EKS, it is important to review the IAM policies and roles associated with the EKS cluster and worker nodes. It may also be necessary to review the logs and error messages to identify the cause of the issue.

Common IAM issues in EKS

IAM (Identity and Access Management) is a key component of Amazon EKS (Elastic Kubernetes Service) and is used to manage access to resources and services in the EKS cluster. IAM roles and policies are used to define and manage permissions for Kubernetes resources running in an EKS cluster. While IAM is a powerful tool for managing access to resources, it can also be a source of issues and errors if not properly configured.

Here are some of the common IAM issues in EKS and how to troubleshoot them:

Access Denied Error

This error occurs when a user or role does not have the required permissions to perform an action on a resource in the EKS cluster. To troubleshoot this error, check the IAM policy associated with the user or role to ensure that it has the required permissions.  

For example, suppose a user is trying to create a new deployment in a namespace within an EKS cluster, and the user gets an Access Denied error. In that case, you can check the IAM policy associated with the user to ensure that it allows the user to create deployments in the specified namespace.

{
 "Version": "2012-10-17",
 "Statement": [
   {
     "Sid": "VisualEditor0",
     "Effect": "Allow",
     "Action": [
       "eks:CreateDeployment",
       "eks:Describe*",
       "eks:List*"
     ],
     "Resource": [
       "arn:aws:eks:us-west-2:123456789012:cluster/my-cluster",
       "arn:aws:eks:us-west-2:123456789012:namespace/mynamespace"
     ]
   }
 ]
}  

In the above example, the IAM policy grants the user permission to create a deployment in the my-namespace namespace within the EKS cluster with the ARN arn:aws:eks:us-west-2:123456789012:cluster/my-cluster

Invalid ARN Error

This error occurs when the ARN (Amazon Resource Name) specified in the IAM policy is invalid or does not match the resource being accessed. To troubleshoot this error, ensure that the ARN specified in the IAM policy is correct and matches the resource being accessed.

For example, suppose a user is trying to create a new deployment in a namespace within an EKS cluster, and the user gets an Invalid ARN error. In that case, you can check the ARN specified in the IAM policy associated with the user to ensure that it matches the resource being accessed.

{
 "Version": "2012-10-17",
 "Statement": [
   {
     "Sid": "VisualEditor0",
     "Effect": "Allow",
     "Action": [
       "eks:CreateDeployment",
       "eks:Describe*",
       "eks:List*"
     ],
     "Resource": [
       "arn:aws:eks:us-west-2:123456789012:cluster/my-cluster",
       "arn:aws:eks:us-west-2:123456789012:namespace/mynamespace"
     ]
   }
 ]
}

In the above example, the ARN specified in the IAM policy must match the ARN of the EKS cluster and namespace being accessed.

AWS Credentials Error

This error occurs when the AWS credentials used to access the EKS cluster are invalid or have expired. To troubleshoot this error, ensure that the AWS credentials are valid and not expired.  

For example, suppose a user is trying to create a new deployment in a namespace within an EKS cluster, and the user gets an AWS Credentials error. In that case, you can check the AWS credentials associated with the user to ensure that they are valid and not expired.

aws sts get-caller-identity

This command retrieves the AWS account ID and IAM user or role name associated with the credentials being used.

Role Mapping Error

This error occurs when there is a misconfiguration in the Kubernetes RBAC configuration that leads to incorrect mapping of IAM roles to Kubernetes roles. To troubleshoot this error, ensure that the Kubernetes RBAC configuration correctly maps IAM roles to Kubernetes roles.  

For example, suppose a user is trying to access a Kubernetes resource, and the user gets a Role Mapping error. In that case, you can check the RBAC configuration to ensure that the IAM role associated with the user is correctly mapped to a Kubernetes role.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
    name: eks-admin
roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: cluster-admin
subjects:
- kind: User
   name: alice@example.com
- kind: User
   name: bob@example.com
- kind: Group
   name: dev@example.com

In the above example, the RBAC configuration maps the IAM roles associated with the users and group to the Kubernetes cluster-admin role.

IAM Policy Limitations Error

This error occurs when the IAM policy associated with a user or role has limitations that prevent the user or role from performing the required action on the EKS cluster. To troubleshoot this error, check the IAM policy to ensure that it does not have any limitations that prevent the user or role from performing the required action.  

For example, suppose a user is trying to create a new deployment in a namespace within an EKS cluster, and the user gets an IAM Policy Limitations error. In that case, you can check the IAM policy associated with the user to ensure that it does not have any limitations that prevent the user from creating a deployment in the specified namespace.

{
 "Version": "2012-10-17",
 "Statement": [
   {
     "Sid": "VisualEditor0",
     "Effect": "Allow",
     "Action": [
       "eks:CreateDeployment",
       "eks:Describe*",
       "eks:List*"
     ],
     "Resource": [
       "arn:aws:eks:us-west-2:123456789012:cluster/my-cluster",
       "arn:aws:eks:us-west-2:123456789012:namespace/mynamespace"
     ],
     "Condition": {
       "StringLike": {
         "aws:userid": "AIDAEXAMPLEUSERID"
       }
     }
   }
 ]
}

In the above example, the IAM policy grants the user permission to create a deployment in the “my-namespace” namespace within the EKS cluster with the ARN arn:aws:eks:us-west-2:123456789012:cluster/my-cluster only if the user’s IAM user ID matches AIDAEXAMPL EUSERID.

In summary, these are some common IAM issues in EKS and the troubleshooting steps to resolve them. By following these troubleshooting steps, you can resolve IAM-related errors and ensure that users and roles have the required permissions to manage resources in the EKS cluster.

Conclusion

In conclusion, while using AWS Elastic Kubernetes Service (EKS) can provide significant benefits in terms of scalability and flexibility, it also comes with its own set of challenges related to Identity and Access Management (IAM) that can have a significant impact on the overall security and stability of your clusters.
By understanding these common issues, taking steps to address them, implementing best practices and staying up to date with the latest security guidelines,
users can effectively manage their EKS clusters, ensure a successful deployment and operation of their EKS clusters and fully leverage the benefits of this powerful technology. With the right approach and attention to detail, AWS EKS can be a valuable tool for modernizing and scaling applications in the cloud.

About Stream Security

Stream.Security delivers the only cloud detection and response solution that SecOps teams can trust. Born in the cloud, Stream’s Cloud Twin solution enables real-time cloud threat and exposure modeling to accelerate response in today’s highly dynamic cloud enterprise environments. By using the Stream Security platform, SecOps teams gain unparalleled visibility and can pinpoint exposures and threats by understanding the past, present, and future of their cloud infrastructure. The AI-assisted platform helps to determine attack paths and blast radius across all elements of the cloud infrastructure to eliminate gaps accelerate MTTR by streamlining investigations, reducing knowledge gaps while maximizing team productivity and limiting burnout.

Tal Shladovsky
Cloud Specialist
Related Articles
All
articles >
No items found.

Step into the Future of SecOps