feat(athena): support ListTagsForResource for workgroups (#3242)

* feat(athena): support ListTagsForResource for workgroups

Fixes #2791. terraform-provider-aws's read/refresh for aws_athena_workgroup
calls ListTagsForResource unconditionally, even when no tags are set,
and floci's Athena handler had no support for the action:

  Error: listing tags for Athena WorkGroup ...: InvalidAction: Action
  ListTagsForResource is not supported

Parses the workgroup name out of the ResourceARN (using the existing
AwsArnUtils helper) and returns the tags already captured on
CreateWorkGroup. The primary workgroup always answers with an empty
list, matching a live account, since CreateWorkGroup already rejects
"primary" and it can never carry real tags. An ARN for an unsupported
resource type, or naming a workgroup that doesn't exist, faults with
InvalidRequestException like the rest of this handler's not-found cases.

* docs(athena): sync the supported-actions table for ListTagsForResource

* fix(athena): reject ListTagsForResource ARNs naming a different service

pgermosen (review): listTagsForResource only checked that the ARN's
resource path started with workgroup/, never the service, so an ARN
naming a completely different service with a coincidentally matching
region and workgroup name resolved instead of being rejected the way
real AWS rejects a ResourceARN naming the wrong service.

Adds the explicit arn.service() == "athena" check, plus a RestAssured
test proving a workgroup-shaped ARN under a different service is
rejected even when a same-named workgroup genuinely exists. Verified by
disabling the check and confirming the new test fails with the exact
expected 400-vs-200 mismatch before restoring it.

Also adds an SDK-client test (AthenaTest, compat suite) round-tripping
ListTagsForResource through the real AthenaClient, per review request to
validate request/response shapes the way other management API PRs do.
This commit is contained in:
Olamide Kosile authored and GitHub committed 2026-09-09 16:27:02 -04:00
1 parent d466ffe099
commit b988dc5d1a
5 files changed
+255

No files matched your search

@@ -326,4 +326,30 @@ class AthenaTest {
}
}
}
/**
* github.com/floci-io/floci/issues/2791: terraform-provider-aws's read/refresh for
* aws_athena_workgroup calls ListTagsForResource unconditionally. Round-trips through the
* real AthenaClient (rather than raw JSON) to validate the request/response shapes.
*/
@Test
@Order(10)
@DisplayName("listTagsForResource returns the tags set on workgroup creation")
void listTagsForResourceReturnsTagsSetOnCreation() {
String groupName = "sdk-tags-" + UUID.randomUUID().toString().replace("-", "").substring(0, 8);
athena.createWorkGroup(CreateWorkGroupRequest.builder()
.name(groupName)
.tags(software.amazon.awssdk.services.athena.model.Tag.builder()
.key("env").value("prod").build())
.build());
ListTagsForResourceResponse response = athena.listTagsForResource(
ListTagsForResourceRequest.builder()
.resourceARN("arn:aws:athena:us-east-1:000000000000:workgroup/" + groupName)
.build());
assertThat(response.tags()).hasSize(1);
assertThat(response.tags().get(0).key()).isEqualTo("env");
assertThat(response.tags().get(0).value()).isEqualTo("prod");
}
}