Add ec2.vpc resource support to Tagging API (#3375)

Closes #1849
This commit is contained in:
Brian Pandola 2020-10-10 11:05:21 -07:00 committed by GitHub
commit 4a336b8b04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import uuid
import six
from boto3 import Session
from moto.core import ACCOUNT_ID
from moto.core import BaseBackend
from moto.core.exceptions import RESTError
@ -367,6 +368,23 @@ class ResourceGroupsTaggingAPIBackend(BaseBackend):
# RedShift Subnet group
# VPC
if (
not resource_type_filters
or "ec2" in resource_type_filters
or "ec2:vpc" in resource_type_filters
):
for vpc in self.ec2_backend.vpcs.values():
tags = get_ec2_tags(vpc.id)
if not tags or not tag_filter(
tags
): # Skip if no tags, or invalid filter
continue
yield {
"ResourceARN": "arn:aws:ec2:{0}:{1}:vpc/{2}".format(
self.region_name, ACCOUNT_ID, vpc.id
),
"Tags": tags,
}
# VPC Customer Gateway
# VPC DHCP Option Set
# VPC Internet Gateway