Skip to content

Commit

Permalink
ResourceGroupsTaggingAPI: fixed tags for Workspaces Web Portals (#8234)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamarcelin authored Oct 18, 2024
1 parent 77fbf51 commit fa4352a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
4 changes: 3 additions & 1 deletion moto/resourcegroupstaggingapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fa4352a

Please sign in to comment.