fix(appconfig): accept top-level resource ARNs in TagResource/ListTagsForResource (#2279)

* fix(appconfig): accept top-level resource ARNs in TagResource/ListTagsForResource

AppConfigTagHandler#parseArn hardcoded the assumption that every AppConfig
resource ARN nests under application/... - true for environment and
configurationprofile, but AWS documents deploymentstrategy, extension, and
extensionassociation as top-level, taggable resources (see e.g. the Tags
property on AWS::AppConfig::DeploymentStrategy/Extension/ExtensionAssociation).
A deploymentstrategy/{id} ARN has parts[0] == "deploymentstrategy", not
"application", so it fell through to the 400 at the end of parseArn.

Adds a TOP_LEVEL_TYPES set for the three non-nested taggable types and checks
it before the application/ branch. Tag storage for these types remains a
no-op (same existing precedent as environment/configurationprofile) - this
fixes the ARN-shape rejection, not tag persistence for new resource types.

Verified real AWS support for all three via CloudFormation's own resource
docs before scoping the fix, since a shared ARN-parsing helper is an easy
place to fix one AWS-compatibility gap while introducing another (e.g.
hostedconfigurationversion, which the existing parts.length==6 branch
already over-accepts despite AWS not supporting tagging it at all - left
untouched here as a separate, pre-existing issue, out of scope for this fix).

* docs(appconfig): clarify no-op-tag javadoc, rename a misleadingly-named test

Review feedback on #2279 (Copilot):

- The class javadoc singled out hostedconfigurationversion as an
  example of something AWS doesn't support tagging for, but the
  existing parts.length==6 branch already accepts (and no-ops) that
  exact ARN shape - describing current behavior generally instead
  (application persisted, everything else recognized-but-no-op) rather
  than calling out one type as if it were rejected.
- Renamed tagExtensionAndExtensionAssociationArnsAreAcceptedNotRejected
  to listTagsForExtensionAndExtensionAssociationArnsIsAcceptedNotRejected
  - the test only ever calls GET (ListTagsForResource), never POST
    (TagResource), so the old name would mislead anyone reading a
    failure.

AppConfigIntegrationTest: 25/25 passed.
This commit is contained in:
sheldon-nadarajah-sft authored and GitHub committed 2026-08-15 13:06:26 -04:00
1 parent 9fccf7cd38
commit 0818e5e2d6
3 files changed
+90 -2

No files matched your search

@@ -8,6 +8,7 @@ import jakarta.inject.Inject;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* {@link TagHandler} implementation for AppConfig.
@@ -17,9 +18,14 @@ import java.util.Map;
* <li>{@code arn:aws:appconfig:<region>:<account>:application/<appId>}
* <li>{@code arn:aws:appconfig:<region>:<account>:application/<appId>/environment/<envId>}
* <li>{@code arn:aws:appconfig:<region>:<account>:application/<appId>/configurationprofile/<profileId>}
* <li>{@code arn:aws:appconfig:<region>:<account>:deploymentstrategy/<strategyId>}
* <li>{@code arn:aws:appconfig:<region>:<account>:extension/<extensionId>}
* <li>{@code arn:aws:appconfig:<region>:<account>:extensionassociation/<associationId>}
* </ul>
* Only application-level tags are stored; environment and configurationprofile tag calls
* are accepted (no-op) to satisfy Terraform provider reads.
* Only application-level tags are actually stored; every other recognized ARN shape above is
* accepted (not rejected with a 400) but the tag call itself is a no-op - this satisfies callers
* (e.g. Terraform's AWS provider) that read tags back after a write without erroring on a resource
* type Floci doesn't yet persist tags for.
*/
@ApplicationScoped
public class AppConfigTagHandler implements TagHandler {
@@ -68,6 +74,13 @@ public class AppConfigTagHandler implements TagHandler {
private record ResourceRef(String type, String id) {}
// The AppConfig resource types AWS documents as taggable that are NOT nested under
// application/... (see e.g. the Tags property on AWS::AppConfig::DeploymentStrategy,
// AWS::AppConfig::Extension, and AWS::AppConfig::ExtensionAssociation) - every other
// taggable type (application, environment, configurationprofile) already nests under
// application/ and is handled by the branch below.
private static final Set<String> TOP_LEVEL_TYPES = Set.of("deploymentstrategy", "extension", "extensionassociation");
private static ResourceRef parseArn(String arn) {
// arn:aws:appconfig:<region>:<account>:<resource>
String resource;
@@ -77,6 +90,9 @@ public class AppConfigTagHandler implements TagHandler {
throw new AwsException("BadRequestException", "Invalid resource ARN: " + arn, 400);
}
String[] parts = resource.split("/");
if (parts.length == 2 && TOP_LEVEL_TYPES.contains(parts[0])) {
return new ResourceRef(parts[0], parts[1]);
}
if (parts.length >= 2 && "application".equals(parts[0])) {
// application/<appId>
if (parts.length == 2) return new ResourceRef("application", parts[1]);