This message was deleted.
# general
s
This message was deleted.
l
Just add the tags to the subnet args object. The tags object can be generated at run time, knowing whether the cluster exists and what the tag value should be.
c
You can create the eks clusters with a predetermined name so you can just create the subnets initially with the correct tag names
1
b
Yes, the predetermined name is the route I took. I don't quite follow how I could generate the tags object at runtime using an object / output that hasn't been created yet? But the predetermined name is working for now, thanks!
l
👍 You wouldn't create it in advance. The tags would be applied after the fact.. on subsequent `up`s
b
Ahhhh I see. Like a "cluster get" or something beforehand that doesn't error if it doesn't exist to get cluster names and create tags from them
l
Yep. So you'd created a tags with nothing, initially; next run, the subnets would be created so the tags would have the required value.
This can be a minor pain to manage with vanilla Pulumi, but if you call it in a script (so that it always ups twice), or use automation-api, then it should be good.
b
That's super clever! Thank you!
Yeah, good to know - the thing that intimidates me most currently is control flow / catching error states by comparing Output objects / etc.
l
Yea that can be annoying. automation-api helps, and so does policy as code.
b
Good to know!! I'll have to take a look at those!
c
@billions-yak-67755 you don’t need to run up twice, just create the subnet with the tags
Copy code
subnetTags := pulumi.All(clusterName, subnetName).ApplyStringMap(func(args []interface{}) map[string]string {
			name := args[0].(string)
			subnet := args[1].(string)
			return map[string]string{
				"Name":                            subnet,
				"<http://kubernetes.io/role/internal-elb|kubernetes.io/role/internal-elb>": "1",
				"<http://kubernetes.io/role/elb|kubernetes.io/role/elb>":          "1", // not sure if we'll need it but let's enable for now.
				"<http://kubernetes.io/cluster/|kubernetes.io/cluster/>" + name:   "shared",
			}
		})

		sub, err2 := pulumiec2.NewSubnet(ctx, fmt.Sprintf("eks-nodegroup-subnet-%d", i+1), &pulumiec2.SubnetArgs{
			AvailabilityZone:    pulumi.String(aws.StringValue(z.ZoneName)),
			CidrBlock:           pulumi.String(fmt.Sprintf("10.0.%d.0/18", (i+1)*64)),
			VpcId:               vpc.ID(),
			MapPublicIpOnLaunch: pulumi.BoolPtr(true),
			Tags:                subnetTags,
		}, pulumi.Provider(p))
That’s what I’m doing
b
Thanks! Yes, that is what I have currently too - just trying to understand the different ways to solve the problem in case the other path is useful to help solve other problems down the road!