I'm sure I'm missing something pretty simple here,...
# general
h
I'm sure I'm missing something pretty simple here, but I can't seem to figure it out or find an answer online. I'm working with an existing EKS cluster and trying import it into Pulumi. I'm using aws-native in Python. The EKS Cluster Resource takes a VPC config. A few of the VPC config properties are arrays, security_group_ids, public_access_cidrs, and subnet_ids are the ones I'm interested in. As I'm importing it, I don't (yet) want to mess with having Pulumi take over the subnets and security groups. So, I'm treating their values as config. As such, I have:
Copy code
project:cluster_security_group_ids:
  - "sg-id"
project:cluster_subnet_ids:
  - "subnet-1"
  - "subnet-2"
In my stack yaml. I have:
Copy code
config = pulumi.Config()
cluster_security_group_ids = config.get_object("cluster_security_group_ids")
cluster_subnet_ids = config.get_object("cluster_subnet_ids")
in my Pulumi Program. I am then using those values in my VPC config
Copy code
vpc_config = pulumi_aws_native.eks.ClusterResourcesVpcConfigArgs(
        endpoint_private_access=False,
        endpoint_public_access=True,
        security_group_ids=cluster_security_group_ids,
        public_access_cidrs=cluster_ip_whitelist,
        subnet_ids=cluster_subnet_ids,
    )
This yields a type error of > Argument of type "Any | None" cannot be assigned to parameter "subnet_ids" of type "Input[Sequence[Input[str]]]" in function "__init__" However, the same approach works for security_group_ids. Any pointers/help would be appreciated. Thanks
d
get_object
isn't strongly typed, as it can be used to get a variety of different types. It's a type hint error, so doesn't block runtime code. To fix, you need to let your code know what the object will be by doing:
subnet_ids: list[str] = config.get_object("subnet_ids")
You may also need to cast it to give a strong hint to the type checker: https://docs.python.org/3/library/typing.html#typing.cast
It's better to use
require_object
too if you expect the config to always be set
h
Thanks for the pointers, I ended up with
cast(Sequence[str], config.cluster_subnet_ids)