aws-cdk-lib.Resource 类型的对象在尝试更新 aws-auth ConfigMap 时不能转换为 aws-cdk-lib.aws_eks.Cluster
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
在尝试编写一个简单的 CDK 脚本来更新 aws-auth ConfigMap 时,我收到错误 Object of type aws-cdk-lib.Resource is not convertible to aws-cdk-lib.aws_eks.Cluster
。该错误似乎源于 Cluster 参考,但我不确定为什么因为 .from_cluster_attributes
returns 一个 ICluster 接口。
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")
The error seems to stem from the Cluster reference, but I'm not sure why since .from_cluster_attributes returns an ICluster interface.
差不多。 AwsAuth
需要一个 Cluster
,而您正在通过 ICluster
。这意味着您无法使用导入的集群创建 AwsAuth
资源。
在尝试编写一个简单的 CDK 脚本来更新 aws-auth ConfigMap 时,我收到错误 Object of type aws-cdk-lib.Resource is not convertible to aws-cdk-lib.aws_eks.Cluster
。该错误似乎源于 Cluster 参考,但我不确定为什么因为 .from_cluster_attributes
returns 一个 ICluster 接口。
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")
The error seems to stem from the Cluster reference, but I'm not sure why since .from_cluster_attributes returns an ICluster interface.
差不多。 AwsAuth
需要一个 Cluster
,而您正在通过 ICluster
。这意味着您无法使用导入的集群创建 AwsAuth
资源。