Kms_key_arn" is not expected here

Hi All,

I am using the latest versions of provider but I am getting this error. Any idea?

module “eks” {
source = “terraform-aws-modules/eks/aws”
version = “~> 20.29.0”

cluster_name = “dev-test2”
cluster_version = “1.31”
cluster_endpoint_public_access = true
kms_key_arn = aws_kms_key.eks_kms_key.arn
vpc_id = “…”

Error is:
Error: Unsupported argument

│ on eks.tf line 71, in module “eks”:
│ 71: kms_key_arn = “aws_kms_key.eks_kms_key.arn”

│ An argument named “kms_key_arn” is not expected here.

The error isn’t referencing the provider, but rather the "eks" module block which isn’t expecting a kms_key_arn argument.

Note also that you are assigning the string literal "aws_kms_key.eks_kms_key.arn" to that input variable, when in all likelihood you should be using a reference to aws_kms_key.eks_kms_key.arn without the quotes.

Thanks. You are right. I was wondering if it’s complaining about kms_key_arn or the assigned value. so I put the double quotes and result did not change.
So even this is failing: kms_key_arn = aws_kms_key.eks_kms_key.arn

Hi @homernajafi

I don’t claim to have specific expertise of AWS but, for what it’s worth, kms_key_arn is an output only of this module. Regardless of what value you assign to it, it’s not a recognised input.

create_kms_key is an input and this is set to “true” as default which appears to create a KMS key for cluster encryption through calling a kms module from within this eks module.

In the kms module, there is a key_arn output that is mapped to the value of aws_kms_key.arn so I think this relationship that you are attempting to set explicitly here (unless I have misinterpreted) is already handled intrinsically, within the eks module and its kms dependency.