Jeremy Cowan
Jeremy Cowan

Reputation: 789

Object of type aws-cdk-lib.Resource is not convertible to aws-cdk-lib.aws_eks.Cluster when trying to update the aws-auth ConfigMap

While trying to write a simple CDK script to update the aws-auth ConfigMap, I get the error Object of type aws-cdk-lib.Resource is not convertible to aws-cdk-lib.aws_eks.Cluster. The error seems to stem from the Cluster reference, but I'm not sure why since .from_cluster_attributes returns an ICluster interface.

class EksCdkStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        cluster = eks.Cluster.from_cluster_attributes(self, "Cluster", cluster_name="megaXL")

        role = iam.Role.from_role_arn(self, "Role", "arn:aws:iam::123456789012:role/delete_me_role")

        eks.AwsAuth(self, "Auth", cluster=cluster).add_role_mapping(role=role, groups="system:masters")

Upvotes: 0

Views: 550

Answers (1)

gshpychka
gshpychka

Reputation: 11588

The error seems to stem from the Cluster reference, but I'm not sure why since .from_cluster_attributes returns an ICluster interface.

Almost. AwsAuth requires a Cluster, and you're passing ICluster. This means that you can't create an AwsAuth resource with an imported Cluster.

Upvotes: 1

Related Questions