https://pulumi.com logo
Title
m

mammoth-airline-91759

12/10/2021, 11:02 PM
I created a VPC like this:
new awsx.ec2.Vpc("vpc-dev-1", {
        cidrBlock: "10.0.0.0/16",
        instanceTenancy: "default",
        numberOfAvailabilityZones: 3,
        numberOfNatGateways: 2,
});
I now realize I need some tags on each public and private subnet. Is there a way to easily go back and add those tags to each subnet without destroying and re-creating the entire stack?
w

wonderful-twilight-70958

12/10/2021, 11:32 PM
b

billowy-army-68599

12/11/2021, 12:20 AM
@mammoth-airline-91759 absolutely! tags are not an immutable API call, so just update your code, something like this:
const vpc = new awsx.ec2.Vpc(`${name}-vpc`, {
    cidrBlock: "172.16.0.0/24",
    subnets: [
        {
            type: "private",
            tags: {
                "<http://kubernetes.io/role/internal-elb|kubernetes.io/role/internal-elb>": "1",
            }
        },
        {
            type: "public",
            tags: {
                "<http://kubernetes.io/role/elb|kubernetes.io/role/elb>": "1",
            }
        }],
    tags: {
        Name: `${name}-vpc`,
        Owner: "lbriggs",
        owner: "lbriggs",
    }
});
m

mammoth-airline-91759

12/11/2021, 1:02 AM
I tried adding the
subnets
array, but the
pulumi up
preview showed replacements for all of the vpc components.
b

billowy-army-68599

12/11/2021, 1:28 AM
ah that's probably because the subnets themselves weren't defined, I'd suggest trying @wonderful-twilight-70958's suggestion
m

mammoth-airline-91759

12/11/2021, 5:47 AM
adding the tags using
ec2.Tag
worked. thanks folks!