diff --git a/moto/resourcegroupstaggingapi/models.py b/moto/resourcegroupstaggingapi/models.py index b384042f6112..19dc9339a8f7 100644 --- a/moto/resourcegroupstaggingapi/models.py +++ b/moto/resourcegroupstaggingapi/models.py @@ -591,7 +591,9 @@ def format_tag_keys( not resource_type_filters or "workspaces-web" in resource_type_filters ): for portal in self.workspacesweb_backends.portals.values(): - tags = format_tag_keys(portal.tags, ["Key", "Value"]) # type: ignore + tags = self.workspacesweb_backends.tagger.list_tags_for_resource( + portal.arn + )["Tags"] if not tags or not tag_filter(tags): continue yield { diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py index fc73f210dcb5..759c44569b7a 100644 --- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py +++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py @@ -1203,3 +1203,40 @@ def test_get_resources_stepfunction(): assert {"Key": "Name", "Value": "Alice"} in resp["ResourceTagMappingList"][0][ "Tags" ] + + +@mock_aws +def test_get_resources_workspacesweb(): + ww_client = boto3.client("workspaces-web", region_name="ap-southeast-1") + arn = ww_client.create_portal( + additionalEncryptionContext={"Key1": "Encryption", "Key2": "Context"}, + authenticationType="Standard", + clientToken="TestClient", + customerManagedKey="abcd1234-5678-90ab-cdef-FAKEKEY", + displayName="TestDisplayName", + instanceType="TestInstanceType", + maxConcurrentSessions=5, + tags=[ + {"Key": "TestKey", "Value": "TestValue"}, + {"Key": "TestKey2", "Value": "TestValue2"}, + ], + )["portalArn"] + rtapi = boto3.client("resourcegroupstaggingapi", region_name="ap-southeast-1") + resp = rtapi.get_resources(ResourceTypeFilters=["workspaces-web"]) + assert len(resp["ResourceTagMappingList"]) == 1 + assert {"Key": "TestKey", "Value": "TestValue"} in resp["ResourceTagMappingList"][ + 0 + ]["Tags"] + resp = rtapi.get_resources( + ResourceTypeFilters=["workspaces-web"], + TagFilters=[{"Key": "TestKey3", "Values": ["TestValue3"]}], + ) + assert len(resp["ResourceTagMappingList"]) == 0 + ww_client.tag_resource( + resourceArn=arn, tags=[{"Key": "TestKey3", "Value": "TestValue3"}] + ) + resp = rtapi.get_resources( + ResourceTypeFilters=["workspaces-web"], + TagFilters=[{"Key": "TestKey3", "Values": ["TestValue3"]}], + ) + assert len(resp["ResourceTagMappingList"]) == 1