https://pulumi.com logo
#aws
Title
# aws
p

polite-student-92901

03/18/2021, 9:53 PM
Hi, is there a way to add tag to the existing resources like subnet? Thanks for the help.
l

little-cartoon-10569

03/18/2021, 9:56 PM
You need to either define the subnet yourself, or add a transformation for it. The transformation can be on the resource, or on the entire stack.
p

polite-student-92901

03/18/2021, 10:04 PM
Thanks for the answer. My use case is that: 1. create vpc with subnets 2. create eks cluster by the vpc 3. tag the subnets with the cluser name Is this doable by Pulumi?
l

little-cartoon-10569

03/18/2021, 10:05 PM
Is the cluster dependent on the subnets?
p

polite-student-92901

03/18/2021, 10:06 PM
Yes, I would say the cluster apply those subnets via the vpc.
l

little-cartoon-10569

03/18/2021, 10:07 PM
It wouldn't be possible in a single stack in Pulumi, I think? And if you use a second stack (and automation-api) to import the subnets and apply the tags, then running the first stack would remove the tags again...
So in short, probably not possible in Pulumi. You may want to use the AWS SDK yourself, from some post-cluster-creation code.
Or, if you know the name of the cluster before creating the VPC (which you probably do?) then tag them at creation time, and use the same name for the cluster.
p

polite-student-92901

03/18/2021, 10:09 PM
yeah I don't know it, cause there will be suffix dynamically generated by Pulumi.
l

little-cartoon-10569

03/18/2021, 10:10 PM
You can do that yourself, or use namePrefix (if it exists) and tag the subnet with that?
No, no namePrefix in cluster 😞
So I think your best option might be to set the name manually. You can either forget about the random suffix (and add deleteBeforeUpdate), or create the random suffix yourself.
p

polite-student-92901

03/19/2021, 1:12 AM
Got it. Thanks!