Skip to content

Allow adding subnet tags per subnet name #900

@rcarpenter79

Description

@rcarpenter79

I would like to add subnet tags that are specific to the name of the subnet.
We have processes that look up what subnet to use based on the configured tags.
I couldn't see an existing way of achieving this.

This functionality would work the same as private_subnet_tags_per_az and public_subnet_tags_per_az but use a map containing the subnet names instead.

I have added the functionality locally to test it worked as expected.

  tags = merge(
    {
      Name = try(
        var.private_subnet_names[count.index],
        format("${var.name}-${var.private_subnet_suffix}-%s", element(var.azs, count.index))
      )
    },
    var.tags,
    var.private_subnet_tags,
    lookup(var.private_subnet_tags_per_az, element(var.azs, count.index), {}),
    try(
      lookup(var.private_subnet_tags_per_subnet, element(var.private_subnet_names, count.index), {}),
      {}
    )
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions