- Newest
- Most votes
- Most comments
The issue you're facing is related to the Key Policy attached to the KMS key used for encrypting the EKS cluster resources. The Key Policy determines which IAM principals (users, roles, or accounts) have access to the KMS key and what operations they can perform.
Even though you have an IAM user with administrator access, the Key Policy on the specific KMS key might not grant the necessary permissions to your IAM user. This is a common security practice to restrict access to sensitive resources like KMS keys, even for administrators.
Here are a few steps you can take to resolve this issue:
-
Identify the KMS Key Policy: First, you need to identify the Key Policy attached to the KMS key in question. You can do this by navigating to the AWS KMS console, selecting the KMS key, and reviewing the "Key Policy" section.
-
Update the Key Policy: If the Key Policy does not include a statement granting your IAM user the necessary permissions (e.g.,
kms:DescribeKey
,kms:Encrypt
,kms:Decrypt
), you'll need to update the Key Policy to grant those permissions.You can update the Key Policy by clicking on the "Key Policy" section in the KMS console, and then clicking "Edit". Add a statement granting your IAM user the required permissions. Here's an example statement:
{ "Sid": "Allow access for my-name@company.com", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::000000000:user/my-name@company.com" }, "Action": [ "kms:DescribeKey", "kms:Encrypt", "kms:Decrypt" ], "Resource": "*" }
Replace
my-name@company.com
with your IAM user name, and000000000
with your AWS account ID. -
Request Access: If you don't have the necessary permissions to update the Key Policy yourself, you'll need to request access from the appropriate team or individual responsible for managing the KMS key.
-
Use an IAM Role with Proper Permissions: Alternatively, instead of using your IAM user, you could create an IAM role with the necessary permissions to access the KMS key and use that role when running Terraform or interacting with the EKS cluster.
By following these steps, you should be able to grant your IAM user (or an IAM role) the necessary permissions to access the KMS key used for encrypting the EKS cluster resources, allowing you to work with the cluster and run Terraform without encountering the AccessDeniedException
.
See the [KMS Key Policies}(https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html) for more information
Relevant content
- asked 2 years ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
Based on your answer I've tried to use the cluster role, but got an error saying I'm not allowed to assume role. I've tried to create a new role instead and provide him all the permission for KMS and EKS (even added administrator in some point), and assumed this role, but got the same error, this time saying the role is not authorized. I guess the next step is asking who ever created the EKS with this KMS to add the policy.