How can I add tags to subnets via LZA?

0

Hi

I'm using LZA - https://docs.aws.amazon.com/solutions/latest/landing-zone-accelerator-on-aws/solution-overview.html - to create VPCs and Subnets. I want to add tags to subnets, but the documentation does not say anything about it. How can I add tags to subnets?

vpcs:
  - name: accelerator-vpc
    account: Network
    region: us-east-1
    cidrs:
      - 10.0.0.0/24
    enableDnsHostnames: true
    enableDnsSupport: true
    instanceTenancy: default
    routeTables:
      - name: accelerator-default
        routes: []
    subnets:
      - name: accelerator-subnet-a
        availabilityZone: a
        # Referencing the route table name
        routeTable: accelerator-default
        ipv4CidrBlock: 10.0.0.0/26
      - name: accelerator-subnet-b
        availabilityZone: b
        # Referencing the route table name
        routeTable: accelerator-default
        ipv4CidrBlock: 10.0.0.64/26
1 Answer
0
Accepted Answer

While the Landing Zone Accelerator (LZA) configuration you've provided doesn't directly show a method for adding tags to subnets, you can typically add tags to AWS resources, including subnets, by including a 'tags' section in the resource definition. For subnets in LZA, you should be able to add tags by including a 'tags' key-value pair within each subnet definition.

Try modifying your subnet configurations like this:

subnets:
  - name: accelerator-subnet-a
    availabilityZone: a
    routeTable: accelerator-default
    ipv4CidrBlock: 10.0.0.0/26
    tags:
      - key: YourTagKey1
        value: YourTagValue1
      - key: YourTagKey2
        value: YourTagValue2
  - name: accelerator-subnet-b
    availabilityZone: b
    routeTable: accelerator-default
    ipv4CidrBlock: 10.0.0.64/26
    tags:
      - key: YourTagKey1
        value: YourTagValue1
      - key: YourTagKey2
        value: YourTagValue2

This approach should allow you to add custom tags to your subnets when they are created through LZA. Remember to replace 'YourTagKey1', 'YourTagValue1', etc., with the actual tag keys and values you want to use.

If this method doesn't work within the LZA framework, you might need to consider alternative approaches, such as using AWS Lambda functions or AWS Systems Manager Automation documents as part of your LZA workflow to add tags to subnets after they are created.
Sources
Transit gateway attachments to a VPC - Network Orchestration for AWS Transit Gateway
Tag subnets for EKS Auto Mode - Amazon EKS

profile picture
answered a month ago
profile pictureAWS
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions