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

bumpy-restaurant-1466

12/26/2019, 1:40 AM
I’m creating an
awsx.ec2.Vpc
with 4 different subnet groups (private, public, db, redis). In order for them to show in the console as sensible name you can include
tags: { Name: "db" }
for each subnet, however unfortunately that results in a subnet group’s subnets having the same name regardless of what az they are in. Instead I’d like to have their names follow the format
example-name-az
or
example-name-number
, eg
example-db-us-west-2
or
example-db-2
. How can I achieve this without needing to specify each az subnet one at a time?
f

flat-insurance-25294

12/26/2019, 3:27 PM
I am also interested in this, sorry I can’t help you here but if you figure it out please do share!
g

gentle-diamond-70147

12/26/2019, 4:57 PM
Here's an example that creates a subnet in each available zone:
Copy code
const zones = aws.getAvailabilityZones().zoneIds;
const subnets = zones.map((zoneId, i) => {
    return new aws.ec2.Subnet(`demo-${i}`, {
        vpcId: vpc.id,
        availabilityZoneId: zoneId,
        cidrBlock: `10.0.${i}.0/22`,
        tags: {
            Name: `demo-${i}`,
        },
    }, { parent: vpc, })
});
2 Views