green-vegetable-15659
02/20/2025, 12:09 PMaws-native
with python
and I'm having an issue with (eks) Nodegroup where I cannot seem to pass tags to the constructor, the same tags work fine for any other resources but in this case lead to :
AssertionError: While processing resource: 'managed-nodes', type 'aws-native:eks:Nodegroup'
AssertionError has risen: While processing input: 'tags', type <class 'str'>, value [<pulumi_aws_native._inputs.TagArgs object at 0x109bcfc20>]
AssertionError has risen: Unexpected type. Expected 'list' got 'typing.Mapping[str, typing.Union[str, typing.Awaitable[str], pulumi.output.Output[NoneType]]]'
the tags I'm passing are basically TagArgs(key="stack", value=pulumi.get_stack())
which works fine in all the other casesmodern-zebra-45309
02/20/2025, 12:25 PMtags
in the NodeGroupArgs
have to be a Mapping[str, str]
, not TagArgs
. In your case, e.g., {"stack": pulumi.get_stack()}
green-vegetable-15659
02/20/2025, 12:29 PMmodern-zebra-45309
02/20/2025, 12:30 PMgreen-vegetable-15659
02/20/2025, 12:31 PMmodern-zebra-45309
02/20/2025, 12:32 PMgreen-vegetable-15659
02/20/2025, 12:33 PMgreen-vegetable-15659
02/20/2025, 2:05 PMimport pulumi
import pulumi_awsx as awsx
import pulumi_eks as eks
from pulumi_aws_native.eks import Nodegroup,NodegroupArgs,NodegroupScalingConfigArgs
from pulumi_aws_native import TagArgs
from pulumi_aws_native.iam import Role,RoleArgs
import json
config = pulumi.Config()
min_cluster_size = config.get_int("minClusterSize", 3)
max_cluster_size = config.get_int("maxClusterSize", 6)
desired_cluster_size = config.get_int("desiredClusterSize", 3)
eks_node_instance_type = config.get("eksNodeInstanceType", "t3.medium")
vpc_network_cidr = config.get("vpcNetworkCidr", "10.0.0.0/16")
eks_vpc = awsx.ec2.Vpc("eks-vpc",
enable_dns_hostnames=True,
cidr_block=vpc_network_cidr)
eks_cluster = eks.Cluster("eks-cluster",
vpc_id=eks_vpc.vpc_id,
authentication_mode=eks.AuthenticationMode.API,
public_subnet_ids=eks_vpc.public_subnet_ids,
private_subnet_ids=eks_vpc.private_subnet_ids,
instance_type=eks_node_instance_type,
desired_capacity=desired_cluster_size,
min_size=min_cluster_size,
max_size=max_cluster_size,
node_associate_public_ip_address=False,
endpoint_private_access=False,
endpoint_public_access=True
)
tag=TagArgs(key="stackName", value=pulumi.get_stack())
eks_nodes_role = Role(resource_name="test-nodes-role",
args=RoleArgs(role_name="test-nodes-role",
assume_role_policy_document=json.dumps({
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "<http://ec2.amazonaws.com|ec2.amazonaws.com>"
},
"Action": "sts:AssumeRole"
}
]
}),
managed_policy_arns=[
"arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly",
"arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy",
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"],
tags=[tag],
),)
Nodegroup(resource_name=f"managed-nodes",
args=NodegroupArgs(cluster_name="eks-cluster",
capacity_type="ON_DEMAND",
node_role=eks_nodes_role.arn,
subnets=eks_vpc.private_subnet_ids,
scaling_config=NodegroupScalingConfigArgs(desired_size=2,
min_size=2,
max_size=3),
tags=[tag], ),
)
[tool.poetry]
name = "nodepools"
package-mode = false
[tool.poetry.dependencies]
pulumi = "~3.147.0"
python = "~3.13"
pulumi-awsx = "2.21.0"
pulumi-eks = "3.8.1"
pulumi-aws-native = "~1.24.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
is enough to repro the issuemodern-zebra-45309
02/20/2025, 2:38 PMRoleArgs
takes tags
as Sequence[TagArgs]
, while NodeGroupArgs
takes tags
as Mapping[str, str]
. https://www.pulumi.com/registry/packages/aws-native/api-docs/iam/role/#tags_python vs https://www.pulumi.com/registry/packages/aws-native/api-docs/eks/nodegroup/#tags_pythonmodern-zebra-45309
02/20/2025, 2:39 PMNodeGroupArgs(tags={"stackName": pulumi.get_stack()}
gives the same error message, right?green-vegetable-15659
02/20/2025, 2:40 PMgreen-vegetable-15659
02/20/2025, 2:41 PMmodern-zebra-45309
02/20/2025, 3:17 PMgreen-vegetable-15659
02/27/2025, 1:41 PMtags={DEFAULT_TAG.key: DEFAULT_TAG.value}
this worked, indeed I could not reuse my TagArgs
in this case, looking at the openapi spec kinda helped but that still feels like the issue
Thanks @modern-zebra-45309 for pointing this out