Hi there, I'm using `aws-native` with `python` and...
# aws
g
Hi there, I'm using
aws-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 :
Copy code
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 cases
m
The
tags
in the
NodeGroupArgs
have to be a
Mapping[str, str]
, not
TagArgs
. In your case, e.g.,
{"stack": pulumi.get_stack()}
g
that doesnt help, i tried a lot of different combinations and they all end up with the assertion error above
m
Can you show a complete code example that can be run?
g
i cannot really share anything i m working on, but maybe i can put up a quick repro
m
I think that's the only way for others to see what you're doing and to determine whether this is a bug or a usage error
g
anyone with a stack and a nodegroup could simply try it out, i got hundreds of resources in my stack that's the only resource failing like so
Copy code
import 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], ),
)
Copy code
[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 issue
m
According to the documentation, I believe it's correct that this does not work.
RoleArgs
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_python
But you said that
NodeGroupArgs(tags={"stackName": pulumi.get_stack()}
gives the same error message, right?
g
yes anything i tried, even a dummy string literal produces this error
i think the Sequence[TagArgs] etc is just a wrapper but is basically the same with more type hinting
m
g
just a quick update:
Copy code
tags={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