CDKTF python : filter Subnet Ids basis on given Tags

subnetData = {
            "availability_zone": "ap-south-1a",
            "vpc_id": data['vpcData']['resourceAttrs'].id,
            "cidr_block": "**.**.**.**/24",
            "map_public_ip_on_launch": True,
            "tags": {
                "Name": "Subnet 1"
            }
    }
    subnet = vpc.Subnet(self, "testSubnet", 
        **subnetData)
    subnetTags = subnet.tags
    
    TerraformOutput(self, "SubnetTags",
                value = subnetTags 
        )

Output on Terminal:
SubnetTags = {
        "Name": "Subnet 1"
 }

I want to get value of SubnetTags ['Name'] but getting error

For some Business logic I have to get value of “Name key” from the Subnet Tags that is not working. I tried multiple way but getting possible in CDKTF python.

Hi @sdubey472 :wave:

you can use a Terraform function to lookup the "Name" property from the tags map:

TerraformOutput(self, "SubnetTags",
  value = Fn.lookup(subnetTags, "Name", "default Name")
)