feat(ssoadmin): serve Identity Center ListInstances (#2581)

* feat(sso): serve Identity Center ListInstances under SWBExternalService

LZA's Custom::GetIdentityCenterInstanceMetadata Lambda calls SSO Admin
ListInstances (target prefix SWBExternalService., the service's AWS-internal
codename, cf. config's StarlingDoveService) and requires exactly one instance
with InstanceArn and IdentityStoreId. Previously no descriptor matched the
target, so the call died with UnknownOperationException. Identifiers are
fixed constants so they survive restarts — LZA persists them into SSM
parameters between stages.

* fix(config): declare ssoadmin enabled toggle in both application.yml files

Upstream's ServiceConfigYamlCoverageTest requires every service config with an
enabled() toggle to declare it explicitly in both files; this branch predates
that test and fails it without the declaration.

* docs(ssoadmin): defer the single-op handler from action-table generation

* docs(ssoadmin): alias the sso descriptor to the IAM page

* fix(ssoadmin): report the caller's account as OwnerAccountId and assert the unsupported-operation error type

* fix(ssoadmin): use UnknownOperationException for unrecognized actions

Matches this codebase's JSON 1.1 dispatch convention (ServiceQuotas, Network
Firewall, and others already use it) and is a real modelled shape unlike the
bare UnsupportedOperation string, which has no Exception suffix and isn't in
sso-admin's error model.

* docs: correct service count to 79 after the #2579 merge

The upstream/main merge (8a4d9bd1b) added two new services
(servicequotas, ram) on top of this branch's own sso-admin
addition. The merge-base count was 76; three disjoint new services
(1 ours + 2 upstream) makes 79, not 78 as the merge commit left it.
This commit is contained in:
Sam Fakhreddine authored and GitHub committed 2026-08-26 22:06:16 -04:00
1 parent 47034394d1
commit a2bd22d5f8
13 files changed
+190 -4

No files matched your search

@@ -672,6 +672,7 @@ public interface EmulatorConfig {
RumServiceConfig rum();
GuardDutyServiceConfig guardduty();
EmrServerlessServiceConfig emrserverless();
SsoAdminServiceConfig ssoadmin();
ServiceQuotasServiceConfig servicequotas();
RamServiceConfig ram();
ControlTowerServiceConfig controltower();
@@ -679,6 +680,11 @@ public interface EmulatorConfig {
EfsServiceConfig efs();
}
interface SsoAdminServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface IotServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -23,6 +23,7 @@ import io.github.hectorvent.floci.services.ce.CostExplorerJsonHandler;
import io.github.hectorvent.floci.services.cloudtrail.CloudTrailJsonHandler;
import io.github.hectorvent.floci.services.applicationautoscaling.ApplicationAutoScalingJsonHandler;
import io.github.hectorvent.floci.services.cloudcontrol.CloudControlJsonHandler;
import io.github.hectorvent.floci.services.ssoadmin.SsoAdminJsonHandler;
import io.github.hectorvent.floci.services.configservice.ConfigServiceJsonHandler;
import io.github.hectorvent.floci.services.cur.CurJsonHandler;
import io.github.hectorvent.floci.services.pricing.PricingJsonHandler;
@@ -108,6 +109,7 @@ public class AwsJson11Controller {
private final ApplicationAutoScalingJsonHandler applicationAutoScalingJsonHandler;
private final CloudHsmV2JsonHandler cloudHsmV2JsonHandler;
private final OrganizationsJsonHandler organizationsJsonHandler;
private final SsoAdminJsonHandler ssoAdminJsonHandler;
private final ServiceQuotasJsonHandler serviceQuotasJsonHandler;
@Inject
@@ -147,6 +149,7 @@ public class AwsJson11Controller {
ApplicationAutoScalingJsonHandler applicationAutoScalingJsonHandler,
CloudHsmV2JsonHandler cloudHsmV2JsonHandler,
OrganizationsJsonHandler organizationsJsonHandler,
SsoAdminJsonHandler ssoAdminJsonHandler,
ServiceQuotasJsonHandler serviceQuotasJsonHandler) {
this.objectMapper = objectMapper;
this.strictBodyReader = objectMapper.reader().with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
@@ -190,6 +193,7 @@ public class AwsJson11Controller {
this.applicationAutoScalingJsonHandler = applicationAutoScalingJsonHandler;
this.cloudHsmV2JsonHandler = cloudHsmV2JsonHandler;
this.organizationsJsonHandler = organizationsJsonHandler;
this.ssoAdminJsonHandler = ssoAdminJsonHandler;
this.serviceQuotasJsonHandler = serviceQuotasJsonHandler;
}
@@ -267,6 +271,7 @@ public class AwsJson11Controller {
// action is authorized against the calling account, so pass that instead of region.
case "organizations" ->
organizationsJsonHandler.handle(action, request, regionResolver.getAccountId());
case "sso" -> ssoAdminJsonHandler.handle(action, request, regionResolver.getAccountId());
case "servicequotas" -> serviceQuotasJsonHandler.handle(
action, request, region, regionResolver.getAccountId());
default -> null;
@@ -385,6 +385,13 @@ public class ResolvedServiceCatalog {
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CloudApiService."), Set.of("cloudcontrolapi"), Set.of(), Set.of()),
// SSO Admin (IAM Identity Center) signs with scope "sso"; its Smithy target
// prefix is the AWS-internal codename SWBExternalService (cf. config's
// StarlingDoveService above).
descriptor("sso", "ssoadmin", config.services().ssoadmin().enabled(), true,
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("SWBExternalService."), Set.of("sso"), Set.of(), Set.of()),
descriptor("autoscaling", "autoscaling", config.services().autoscaling().enabled(), true,
"autoscaling", config.storage().mode(), 5000L, AwsNamespaces.AUTOSCALING, ServiceProtocol.QUERY,
protocols(ServiceProtocol.QUERY),
@@ -0,0 +1,41 @@
package io.github.hectorvent.floci.services.ssoadmin;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.github.hectorvent.floci.core.common.AwsException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
@ApplicationScoped
public class SsoAdminJsonHandler {
private final SsoAdminService service;
private final ObjectMapper mapper;
@Inject
public SsoAdminJsonHandler(SsoAdminService service, ObjectMapper mapper) {
this.service = service;
this.mapper = mapper;
}
public Response handle(String action, JsonNode request, String callerAccountId) {
return switch (action) {
case "ListInstances" -> listInstances(callerAccountId);
default -> throw new AwsException("UnknownOperationException",
"Operation " + action + " is not supported.", 400);
};
}
private Response listInstances(String callerAccountId) {
ObjectNode response = mapper.createObjectNode();
ObjectNode instance = response.putArray("Instances").addObject();
instance.put("InstanceArn", service.getInstanceArn());
instance.put("IdentityStoreId", service.getIdentityStoreId());
instance.put("Name", "floci-identity-center");
instance.put("OwnerAccountId", callerAccountId);
instance.put("Status", "ACTIVE");
return Response.ok(response).build();
}
}
@@ -0,0 +1,27 @@
package io.github.hectorvent.floci.services.ssoadmin;
import jakarta.enterprise.context.ApplicationScoped;
/**
* IAM Identity Center (SSO Admin) business logic.
*
* <p>Models the single organization Identity Center instance LZA's
* Custom::GetIdentityCenterInstanceMetadata Lambda expects: its {@code ListInstances} call
* succeeds only when exactly one instance is returned, carrying both {@code InstanceArn} and
* {@code IdentityStoreId}. The identifiers are fixed so they stay stable across calls and
* container restarts — LZA persists them into SSM parameters between stages.
*/
@ApplicationScoped
public class SsoAdminService {
private static final String INSTANCE_ARN = "arn:aws:sso:::instance/ssoins-7223b02a5d9f7c8e";
private static final String IDENTITY_STORE_ID = "d-9067f2a3c1";
public String getInstanceArn() {
return INSTANCE_ARN;
}
public String getIdentityStoreId() {
return IDENTITY_STORE_ID;
}
}