From 03a1bf54ed4b04622ee04b08d6a355267b1fb8d1 Mon Sep 17 00:00:00 2001 From: Silvio Vasiljevic Date: Mon, 23 Sep 2024 14:10:05 +0200 Subject: [PATCH] Add output of VPC subnet tagging to resourcegroupstaggingapi --- moto/resourcegroupstaggingapi/models.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/moto/resourcegroupstaggingapi/models.py b/moto/resourcegroupstaggingapi/models.py index f704b860936b..b9bad8419261 100644 --- a/moto/resourcegroupstaggingapi/models.py +++ b/moto/resourcegroupstaggingapi/models.py @@ -663,12 +663,27 @@ def format_tag_keys( "ResourceARN": f"arn:{self.partition}:ec2:{self.region_name}:{self.account_id}:vpc/{vpc.id}", "Tags": tags, } + # VPC Subnet + if ( + not resource_type_filters + or "ec2" in resource_type_filters + or "ec2:subnet" in resource_type_filters + ): + for subnet in self.ec2_backend.subnets.values(): + for subnet_id in subnet.keys(): + tags = format_tags(self.ec2_backend.tags.get(subnet_id, {})) + if not tags or not tag_filter(tags): + continue + yield { + "ResourceARN": f"arn:{self.partition}:ec2:{self.region_name}:{self.account_id}:subnet/{subnet_id}", + "Tags": tags, + } + # VPC Customer Gateway # VPC DHCP Option Set # VPC Internet Gateway # VPC Network ACL # VPC Route Table - # VPC Subnet # VPC Virtual Private Gateway # VPC VPN Connection