Hi All, trying to create a VPC using `pulumi-awsx`...
# aws
p
Hi All, trying to create a VPC using
pulumi-awsx
. The snippet below works, however I need to add a set of tags to the private subnets that are generated, as well as adding a different set of tags to the public subnets. Conceptually, I understand that I need to add the tags before Pulumi creates the resources, but I am not sure how to go about that, even for all subnets. There's an arg called
subnet_specs
but adding tags is not an option. There's also the
tags
are for the
Vpc
, but that just adds tags to the VPC. Help?
Copy code
import pulumi
import pulumi_awsx as awsx

config = pulumi.Config()
vpc_network_cidr = config.get("vpcNetworkCidr", "10.0.0.0/16")

# Create a VPC for the EKS cluster
eks_vpc = awsx.ec2.Vpc(
    "eks-vpc", enable_dns_hostnames=True, cidr_block=vpc_network_cidr,
)
s
There's a bug we need to resolve: https://github.com/pulumi/pulumi-awsx/issues/922
👀 1
The tags should go in
subnet_specs
and should be applied. (They are not, which is the issue.)
🙏 1
p
Hi @stocky-restaurant-98004, I'm hitting a TypeError when I try running a variation of your example. Is that expected? I interpreted the issue to be that the code ran fine, but just didn't apply the tags.
Copy code
error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/Users/cmarteepants/PycharmProjects/env-bootstrapper/./__main__.py", line 23, in <module>
        awsx.ec2.SubnetSpecArgs(
    TypeError: SubnetSpecArgs.__init__() got an unexpected keyword argument 'tags'
Copy code
eks_vpc = awsx.ec2.Vpc(
    "eks-vpc", awsx.ec2.VpcArgs(
        enable_dns_hostnames=True,
        cidr_block=vpc_network_cidr,
        subnet_specs=[
            awsx.ec2.SubnetSpecArgs(
                type=awsx.ec2.SubnetType.PUBLIC,
                tags={"ingress": "HECK YEAH, BUDDY!"}
            ),
            awsx.ec2.SubnetSpecArgs(
                type=awsx.ec2.SubnetType.PRIVATE,
                tags={"ingress": "NO WAY, JOSE"}
            )
        ],
        tags={
            "createdBy": "Constance"
        }
    )
)
s
I don't see anything obviously wrong with that example. I suspect some sort of syntax error (misplaced or missing comma or something).
p
I don't know either. May have been due to all the weird things I was trying while troubleshooting. Nuked my virtualenv and created a new stack. No tags (as expected) but at least the code snippet ran.
I'll track the issue, appreciate your help 🙂
g
I did not read the thread but I'd recommend using transforms for tagging.