https://pulumi.com logo
#getting-started
Title
# getting-started
b

best-winter-27868

06/14/2022, 8:26 PM
i’m trying to alter the tags on the subnets made by the awsx.ec2.Vpc class, but struggling to figure out how that’s done in python, and haven’t had any luck in finding anything that isn’t in typescript. Can anyone give any pointers on how that’s done ? It doesn’t seem to form part of the SubnetSpecArgs class so i guess it’s done in some other way. The typescript seems to access a ‘subnets’ attribute of the class, but that doesn’t seem to be a thing in python unless i’m misreading the source.
l

little-cartoon-10569

06/14/2022, 8:51 PM
AWSX, and all other convenience wrappers, will necessarily expose a smaller number of configuration options than the resources they're built on. If setting subnet tags via the Vpc constructor isn't possible (and it likely isn't), then you can use a transformation to achieve the same thing.
b

best-winter-27868

06/14/2022, 9:05 PM
hmm, thanks for that. Apparently that’s going to be beyond my brain power to pull off, but thanks for the pointer 👍
l

little-cartoon-10569

06/14/2022, 9:45 PM
It's not hard, I'm happy to help.
You define a function that adds tags to subnets: it'll be very like the one in the example code on that page, but only checking for
args.type_ == "aws:ec2/subnet:Subnet"
, and setting
tags
instead of
ignore_changes
.
Then you pass that function as a transformation to your awsx.ec2.Vpc constructor, just like in the last line of the example code.
b

best-winter-27868

06/14/2022, 9:48 PM
i’ll give that a shot. uno momento.
i think the things that tripped me up was 1) what myvpccomponent was meant to be (possibly because i dont know what a component is in the first place, if thats a thing), and 2) i’m going to need to set the tags on the subnets differently based on which type of subnet it is, and this seems to be returning a single value which would include the tags. So somewhere in there i’m going to need to lookup what type of subnet it is.
l

little-cartoon-10569

06/14/2022, 10:07 PM
If the logic is too complex, this suggests to be that you shouldn't be using awsx.ec2.Vpc. You'd be better off with the additional control you get from aws.ec2.Vpc.
b

best-winter-27868

06/14/2022, 10:11 PM
yeah ok. makes sense. 👍
l

little-cartoon-10569

06/14/2022, 10:12 PM
It's the old convention-over-configuration thing 🙂 Once you're configuring your conventionally-created resources... yeah, nah! (As we say here in New Zealand)
7 Views