https://pulumi.com logo
#golang
Title
# golang
g

gifted-fall-44000

12/12/2022, 5:53 PM
Anyone have a nice pattern to apply Tags to the AWS Native Resources which now have custom specific Tag Array Type?
Copy code
&ec2.SubnetArgs{
			AvailabilityZone: pulumi.String(azResult.Azs[i]),
			CidrBlock:        cidr,
			VpcId:            infra.Vpc.ID(),
			Tags: &ec2.SubnetTagArray{},
		}
I'm attempting to iterate over a map of strings to append to this specific type but it is not iterable.
m

many-telephone-49025

12/12/2022, 7:19 PM
Hi @gifted-fall-44000, how about this?
Copy code
var subnetTags ec2.SubnetTagArray
		var mapOfStrings map[string]string
		for k, v := range mapOfStrings {
			subnetTags = append(subnetTags, ec2.SubnetTagArgs{
				Key:   pulumi.String(k),
				Value: pulumi.String(v),
			})
		}

		ec2.SubnetArgs{
			VpcId:            pulumi.String("vpc-12345678"),
			AvailabilityZone: pulumi.String("us-west-2a"),
			CidrBlock:        pulumi.String(""),
			Tags:             subnetTags,
		}
4 Views