diff --git a/README.md b/README.md
index b596d7a8b7..bc6fe97e92 100644
--- a/README.md
+++ b/README.md
@@ -178,7 +178,7 @@ LocalStack's community edition [sunset in March 2026](https://blog.localstack.cl
| CodeBuild | Real Docker execution | No |
| Native binary | ~40 MB | No |
-**76 AWS services. Broad coverage. Free forever.**
+**78 AWS services. Broad coverage. Free forever.**
## Architecture Overview
@@ -226,7 +226,7 @@ Floci supports local emulation for application services, data services, eventing
| Data, analytics, and AI | Athena, Glue, EMR, Firehose, Managed Service for Apache Flink, OpenSearch, S3 Tables, S3 Vectors, Textract, Transcribe, Bedrock Runtime, Bedrock AgentCore |
| Databases and caching | RDS, RDS Data API, Neptune, DocumentDB, MemoryDB, ElastiCache |
| Messaging and transfer | SES, Kinesis, MSK, Amazon MQ, Transfer Family, IoT Core |
-| Security and governance | WAF v2, CloudTrail, CloudFront, Resource Groups Tagging API, Resource Explorer 2, CloudHSM v2, Organizations |
+| Security and governance | AWS RAM, Service Quotas, WAF v2, CloudTrail, CloudFront, Resource Groups Tagging API, Resource Explorer 2, CloudHSM v2, Organizations |
| Cost and billing | Pricing, Cost Explorer, Cost and Usage Reports, BCM Data Exports |
| Resilience, backup, and config | AWS FIS, AWS Backup, AWS Config, AppConfig, AppConfigData, CloudFormation, Cloud Control API |
@@ -291,6 +291,8 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
| CodeBuild | In-process with real Docker | Real buildspec execution, CloudWatch logs, S3 artifacts |
| CodeDeploy | In-process with Lambda traffic shifting | Deployment groups, configs, lifecycle hooks, auto-rollback |
| CodePipeline | In-process orchestration | Pipelines, executions, S3 artifacts, approvals, local providers, custom workers |
+| Service Quotas | In-process | Generated quota catalog with generous static values; real quota codes for CodeBuild and Lambda concurrency |
+| AWS RAM | In-process | EnableSharingWithAwsOrganization opt-in |
| AWS Batch | In-process | Compute environments, job queues, job definitions, job submission and lifecycle |
| Auto Scaling | In-process with reconciler | Launch configs, ASGs, desired capacity reconciliation, lifecycle hooks |
| Application Auto Scaling | In-process | Scalable targets, target-tracking and step scaling policies, CloudWatch alarm creation, tagging (policies are stored but inert) |
diff --git a/docs/configuration/advanced/application-yml.md b/docs/configuration/advanced/application-yml.md
index a3d94387c4..b41c122386 100644
--- a/docs/configuration/advanced/application-yml.md
+++ b/docs/configuration/advanced/application-yml.md
@@ -155,6 +155,13 @@ floci:
enforcement-enabled: false # Set to true to enforce IAM policies on all requests
seed-deployer-principal: false # Set to true to create a local floci-deployer admin principal
+ servicequotas:
+ enabled: true
+
+ ram:
+ enabled: true
+
+
elasticache:
enabled: true
proxy-base-port: 6379
diff --git a/docs/configuration/environment-variables.md b/docs/configuration/environment-variables.md
index 2ff3c6e231..72bdf2cebb 100644
--- a/docs/configuration/environment-variables.md
+++ b/docs/configuration/environment-variables.md
@@ -457,6 +457,8 @@ These services spawn Docker containers. They require access to the Docker socket
| `FLOCI_SERVICES_CODEBUILD_ENABLED` | `true` | Enable the CodeBuild service |
| `FLOCI_SERVICES_CODEBUILD_DOCKER_NETWORK` | _(none)_ | Docker network for CodeBuild build containers |
| `FLOCI_SERVICES_CODEDEPLOY_ENABLED` | `true` | Enable the CodeDeploy service |
+| `FLOCI_SERVICES_SERVICEQUOTAS_ENABLED` | `true` | Enable the Service Quotas service |
+| `FLOCI_SERVICES_RAM_ENABLED` | `true` | Enable the AWS RAM service |
| `FLOCI_SERVICES_BACKUP_ENABLED` | `true` | Enable the AWS Backup service |
| `FLOCI_SERVICES_BACKUP_JOB_COMPLETION_DELAY_SECONDS` | `3` | Simulated delay before backup jobs transition to `COMPLETED` |
| `FLOCI_SERVICES_FIS_ENABLED` | `true` | Enable the AWS Fault Injection Service management API |
diff --git a/docs/index.md b/docs/index.md
index 816cad8925..9af7ce3b23 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -12,7 +12,7 @@ Floci is a fast, free, and open-source local AWS service emulator built for deve
## Supported Services
-Floci emulates 73 AWS services. See the [Services Overview](services/index.md) for per-service operation counts, endpoints, and full protocol details.
+Floci emulates 78 AWS services. See the [Services Overview](services/index.md) for per-service operation counts, endpoints, and full protocol details.
| Service | Protocol |
|---|---|
@@ -80,6 +80,8 @@ Floci emulates 73 AWS services. See the [Services Overview](services/index.md) f
| Cost and Usage Reports | JSON 1.1 |
| BCM Data Exports | JSON 1.1 |
| Transfer Family | JSON 1.1 |
+| AWS RAM | REST JSON |
+| Service Quotas | JSON 1.1 |
## Why Floci?
@@ -115,7 +117,7 @@ docker compose up -d
aws --endpoint-url http://localhost:4566 s3 mb s3://my-bucket
```
-All 73 AWS services are immediately available at `http://localhost:4566`.
+All 78 AWS services are immediately available at `http://localhost:4566`.
[Get started →](getting-started/quick-start.md){ .md-button .md-button--primary }
[View services →](services/index.md){ .md-button }
diff --git a/docs/services/index.md b/docs/services/index.md
index 5b27619fc5..469f6b30a5 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -1,6 +1,6 @@
# Services Overview
-Floci emulates 76 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.
+Floci emulates 78 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.
This page is the canonical reference for supported service and operation counts. Some services expose separate control-plane and data-plane rows below. Other docs (and the README) should link here rather than duplicating the table.
@@ -85,6 +85,8 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [AWS Batch](batch.md) | `/v1/...` | REST JSON | 10 |
| [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 30 |
| [CodePipeline](codepipeline.md) | `POST /` + `X-Amz-Target: CodePipeline_20150709.*` | JSON 1.1 | 44 |
+| [Service Quotas](servicequotas.md) | `POST /` + `X-Amz-Target: ServiceQuotasV20190624.*` | JSON 1.1 | 5 |
+| [AWS RAM](ram.md) | `POST /{operationname}` (lowercase), `DELETE /deleteresourceshare` | REST JSON | 12 |
| [Control Tower](controltower.md) | `/list-landingzones`, `/get-landingzone`, `/create-landingzone`, `/*-baseline*` | REST JSON | 15 |
| [AWS Backup](backup.md) | `/backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 20 |
| [AWS FIS](fis.md) | `/experimentTemplates/*`, `/experiments/*`, `/actions/*`, `/targetResourceTypes/*`, `/safetyLevers/*`, `/tags/*` | REST JSON | 26 |
diff --git a/docs/services/ram.md b/docs/services/ram.md
new file mode 100644
index 0000000000..954b7ee499
--- /dev/null
+++ b/docs/services/ram.md
@@ -0,0 +1,86 @@
+# AWS RAM
+
+**Protocol:** REST JSON
+**Endpoint:** `http://localhost:4566`
+**Signing name:** `ram`
+
+Floci implements the AWS Resource Access Manager calls AWS Landing Zone Accelerator makes
+while bootstrapping shared Transit Gateway attachments and other cross-account resources:
+the organization-sharing opt-in, resource-share CRUD, association management, principal
+listing, and tagging. Sharing is modeled as a flat in-memory store, not full RAM semantics —
+see Current Scope below for what's simplified.
+
+## Supported Actions
+
+
+| Action | Description |
+| --- | --- |
+| `EnableSharingWithAwsOrganization` | Enables resource sharing within the organization; returns `{"returnValue": true}`. Idempotent, no disable counterpart, matching real AWS (`POST /enablesharingwithawsorganization`) |
+| `CreateResourceShare` | Creates a resource share with the given name, principals, and resource ARNs (`POST /createresourceshare`) |
+| `GetResourceShares` | Lists resource shares visible to the caller, `SELF` owned or `OTHER-ACCOUNTS` shared in (`POST /getresourceshares`) |
+| `DeleteResourceShare` | Marks a share `DELETED`, a soft delete matching real AWS's async-then-terminal status (`DELETE /deleteresourceshare`) |
+| `UpdateResourceShare` | Renames a share and/or toggles `allowExternalPrincipals` (`POST /updateresourceshare`) |
+| `AssociateResourceShare` | Adds resource ARNs and/or principals to an existing share (`POST /associateresourceshare`) |
+| `DisassociateResourceShare` | Removes resource ARNs and/or principals from a share (`POST /disassociateresourceshare`) |
+| `ListPrincipals` | Lists principals associated with visible shares (`POST /listprincipals`) |
+| `TagResource` | Adds/overwrites tags on a resource share (`POST /tagresource`) |
+| `UntagResource` | Removes tags by key from a resource share (`POST /untagresource`) |
+| `GetResourceShareInvitations` | Always returns an empty list — organization sharing auto-accepts, so invitations never exist here (`POST /getresourceshareinvitations`) |
+| `ListResources` | Lists shared resource ARNs, with the RAM resource type derived from the ARN, e.g. `ec2:TransitGateway` (`POST /listresources`) |
+
+
+## Configuration
+
+| Environment variable | Default | Description |
+| --- | --- | --- |
+| `FLOCI_SERVICES_RAM_ENABLED` | `true` | Enables the service |
+
+## Example
+
+```bash
+aws --endpoint-url http://localhost:4566 ram enable-sharing-with-aws-organization
+
+aws --endpoint-url http://localhost:4566 ram create-resource-share \
+ --name my-share \
+ --resource-arns arn:aws:ec2:us-east-1:000000000000:transit-gateway/tgw-0abc \
+ --principals arn:aws:organizations::000000000000:ou/o-abc/ou-infra
+
+aws --endpoint-url http://localhost:4566 ram delete-resource-share \
+ --resource-share-arn arn:aws:ram:us-east-1:000000000000:resource-share/...
+```
+
+## Current Scope
+
+- Visibility is simplified: `OTHER-ACCOUNTS` shows every non-owned share regardless of
+ principal targeting, since launched-container credentials all resolve to the same default
+ account and a principal-based check would hide shares from consumers that should see them.
+ LZA's `Custom::GetResourceShare` Lambda filters client-side by `owningAccountId` + `name`
+ anyway, so this doesn't affect that flow.
+- Mutations are owner-only: a caller that is not the share's owning account gets
+ `UnknownResourceException`, the same error an unknown ARN gets, since AWS resolves a share
+ ARN within the caller's own account. Visibility above is unaffected.
+- `resourceOwner` is required on `GetResourceShares`, `ListPrincipals` and `ListResources`: a
+ missing or unmodelled value is rejected with `InvalidParameterException` rather than defaulted
+ to `SELF`.
+- `GetResourceShares` applies the `name`, `resourceShareArns` and `resourceShareStatus` filters;
+ `tagFilters`, `permissionArn`, `permissionVersion` and pagination (`nextToken`/`maxResults`)
+ are accepted but ignored — every matching share is returned in one page.
+- Operations outside the table above are not routed. RAM's paths are matched literally, so an
+ unimplemented operation falls through to S3's `/{bucket}` route and comes back as an S3
+ `NoSuchBucket` XML body where the SDK expects JSON — not a modeled `UnknownOperationException`.
+ If a client reports an XML parse error against a RAM call, that is the cause, not credentials.
+ `GetResourceShareAssociations` is the one most likely to be hit: Terraform's
+ `aws_ram_resource_association` and `aws_ram_principal_association` read it on every refresh.
+- `AssociateResourceShare`/`DisassociateResourceShare` responses synthesize one
+ `resourceShareAssociation` row per requested ARN/principal rather than tracking real
+ per-association status transitions (e.g. no `ASSOCIATING`/`DISASSOCIATING` intermediate
+ state — everything completes synchronously).
+- `TagResource`/`UntagResource` only support tagging by `resourceShareArn`; tagging an
+ individual shared resource via `resourceArn` is not modeled (RAM's `TagResource` accepts
+ either, but LZA only tags shares).
+- Permission-related operations are not implemented: `CreatePermission`,
+ `AssociateResourceSharePermission`, `ListPermissions`, and the rest of the permission-version
+ family. Shares created here always use RAM's default managed permission implicitly — there
+ is no explicit permission model to associate or version.
+- `AcceptResourceShareInvitation` / `RejectResourceShareInvitation` are not implemented —
+ moot under organization sharing, which never produces invitations to begin with.
diff --git a/docs/services/servicequotas.md b/docs/services/servicequotas.md
new file mode 100644
index 0000000000..37c7ef4d55
--- /dev/null
+++ b/docs/services/servicequotas.md
@@ -0,0 +1,67 @@
+# Service Quotas
+
+**Protocol:** JSON 1.1 (`X-Amz-Target: ServiceQuotasV20190624.*`)
+**Endpoint:** `POST http://localhost:4566/`
+**Signing name:** `servicequotas`
+
+Floci answers Service Quotas lookups from a generated in-memory catalog. Every service code
+resolves to a quota list: a curated set with real AWS quota codes where tooling depends on
+them — CodeBuild's `L-2DC20C30` ("Concurrently running builds") and Lambda's `L-B99A9384`
+("Concurrent executions") — plus a deterministic generic set for any other service code. All
+values are deliberately generous (5000) so local pipelines that gate on quota headroom, such
+as AWS Landing Zone Accelerator, never stall on a limit the emulator does not enforce.
+
+Applied quotas and AWS default quotas return the same data, and quota values are static.
+`RequestServiceQuotaIncrease` is accepted and validated but does not change any quota value —
+see Limitations.
+
+## Supported Actions
+
+
+| Action | Description |
+| --- | --- |
+| `ListServiceQuotas` | Lists the quotas for a service code; generated quotas for unknown codes |
+| `GetServiceQuota` | Returns one quota by service and quota code, else `NoSuchResourceException` |
+| `GetAWSDefaultServiceQuota` | Same as GetServiceQuota; defaults equal applied values |
+| `ListAWSDefaultServiceQuotas` | Same as ListServiceQuotas; defaults equal applied values |
+| `RequestServiceQuotaIncrease` | Validates and echoes an increase request as `PENDING`; not persisted, quota unchanged |
+
+
+## Limitations
+
+- **Quota increase requests are not persisted.** `RequestServiceQuotaIncrease` validates its
+ input, resolves the quota, and returns a well-formed `RequestedQuota`, but keeps no state.
+ The request is observable only in the response that creates it.
+- **`Status` is always `PENDING` and never advances.** Nothing processes requests, so no
+ request ever reaches `APPROVED`, `CASE_OPENED`, or `DENIED`. `PENDING` is what real AWS
+ returns on creation, so a caller that only reads the creation response sees faithful data;
+ a caller that polls for completion will wait forever.
+- **Unknown service codes generate a quota catalog rather than failing.** This is deliberate, so
+ the code has to be well-formed to be trusted: `ServiceCode` is validated against the modeled
+ `[a-zA-Z][a-zA-Z0-9-]{1,63}` (max 63 characters) and a malformed one is rejected with
+ `IllegalArgumentException` instead of returning invented quotas.
+- **A requested increase does not change the quota.** `GetServiceQuota` continues to return
+ the catalog value after a successful increase request. Quota values remain static by design
+ so pipelines never stall on an unenforced limit.
+- `GetRequestedServiceQuotaChange` and `ListRequestedServiceQuotaChangeHistory` are not
+ implemented — there is no request store for them to read.
+- `CaseId` is never returned; no support case is opened. `SupportCaseAllowed` in the request is
+ accepted and ignored, as the emulator has no case-opening path either way.
+- The quota-increase template operations (`PutServiceQuotaIncreaseRequestIntoTemplate` and
+ related) are not implemented.
+
+## Configuration
+
+| Environment variable | Default | Description |
+| --- | --- | --- |
+| `FLOCI_SERVICES_SERVICEQUOTAS_ENABLED` | `true` | Enables the service |
+
+## Example
+
+```bash
+aws --endpoint-url http://localhost:4566 service-quotas list-service-quotas \
+ --service-code codebuild
+
+aws --endpoint-url http://localhost:4566 service-quotas get-service-quota \
+ --service-code codebuild --quota-code L-2DC20C30
+```
diff --git a/mkdocs.yml b/mkdocs.yml
index 2198742f13..594261d641 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -137,6 +137,8 @@ nav:
- AWS Batch: services/batch.md
- CodeDeploy: services/codedeploy.md
- CodePipeline: services/codepipeline.md
+ - Service Quotas: services/servicequotas.md
+ - AWS RAM: services/ram.md
- AWS Backup: services/backup.md
- AWS FIS: services/fis.md
- CloudTrail: services/cloudtrail.md
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 8507f2ca55..b278677272 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -672,9 +672,9 @@ public interface EmulatorConfig {
RumServiceConfig rum();
GuardDutyServiceConfig guardduty();
EmrServerlessServiceConfig emrserverless();
-
+ ServiceQuotasServiceConfig servicequotas();
+ RamServiceConfig ram();
ControlTowerServiceConfig controltower();
-
LakeFormationServiceConfig lakeformation();
EfsServiceConfig efs();
}
@@ -725,6 +725,16 @@ public interface EmulatorConfig {
boolean enabled();
}
+ interface ServiceQuotasServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
+ interface RamServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
interface LakeFormationServiceConfig {
@WithDefault("true")
boolean enabled();
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java
index 3d368eccf9..5a75eed20f 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsJson11Controller.java
@@ -41,6 +41,7 @@ import io.github.hectorvent.floci.services.kinesisanalytics.KinesisAnalyticsV2Js
import io.github.hectorvent.floci.services.kms.KmsJsonHandler;
import io.github.hectorvent.floci.services.secretsmanager.SecretsManagerJsonHandler;
import io.github.hectorvent.floci.services.organizations.OrganizationsJsonHandler;
+import io.github.hectorvent.floci.services.servicequotas.ServiceQuotasJsonHandler;
import io.github.hectorvent.floci.services.ssm.Ec2MessagesJsonHandler;
import io.github.hectorvent.floci.services.ssm.SsmJsonHandler;
import jakarta.inject.Inject;
@@ -107,6 +108,7 @@ public class AwsJson11Controller {
private final ApplicationAutoScalingJsonHandler applicationAutoScalingJsonHandler;
private final CloudHsmV2JsonHandler cloudHsmV2JsonHandler;
private final OrganizationsJsonHandler organizationsJsonHandler;
+ private final ServiceQuotasJsonHandler serviceQuotasJsonHandler;
@Inject
public AwsJson11Controller(ObjectMapper objectMapper, ResolvedServiceCatalog catalog,
@@ -144,7 +146,8 @@ public class AwsJson11Controller {
CloudControlJsonHandler cloudControlJsonHandler,
ApplicationAutoScalingJsonHandler applicationAutoScalingJsonHandler,
CloudHsmV2JsonHandler cloudHsmV2JsonHandler,
- OrganizationsJsonHandler organizationsJsonHandler){
+ OrganizationsJsonHandler organizationsJsonHandler,
+ ServiceQuotasJsonHandler serviceQuotasJsonHandler) {
this.objectMapper = objectMapper;
this.strictBodyReader = objectMapper.reader().with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
this.catalog = catalog;
@@ -187,6 +190,7 @@ public class AwsJson11Controller {
this.applicationAutoScalingJsonHandler = applicationAutoScalingJsonHandler;
this.cloudHsmV2JsonHandler = cloudHsmV2JsonHandler;
this.organizationsJsonHandler = organizationsJsonHandler;
+ this.serviceQuotasJsonHandler = serviceQuotasJsonHandler;
}
@POST
@@ -263,6 +267,8 @@ 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 "servicequotas" -> serviceQuotasJsonHandler.handle(
+ action, request, region, regionResolver.getAccountId());
default -> null;
};
// catalog.matchTarget is protocol-agnostic: a JSON 1.0 target
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
index 76aa972b70..7e73adb2d9 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
@@ -355,6 +355,15 @@ public class ResolvedServiceCatalog {
config.storage().services().codepipeline().flushIntervalMs(), null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CodePipeline_20150709."), Set.of("codepipeline"), Set.of(), Set.of()),
+ descriptor("servicequotas", "servicequotas", config.services().servicequotas().enabled(), true,
+ null, null, 5000L, null, ServiceProtocol.JSON,
+ protocols(ServiceProtocol.JSON),
+ Set.of("ServiceQuotasV20190624."), Set.of("servicequotas"), Set.of(), Set.of()),
+ descriptor("ram", "ram", config.services().ram().enabled(), true,
+ null, null, 5000L, null, ServiceProtocol.REST_JSON,
+ protocols(ServiceProtocol.REST_JSON),
+ Set.of(), Set.of("ram"), Set.of(),
+ Set.of(io.github.hectorvent.floci.services.ram.RamController.class)),
descriptor("config", "configservice", config.services().configservice().enabled(), true,
"config", storageMode(config.storage().services().config().mode(), config.storage().mode()),
config.storage().services().config().flushIntervalMs(), null, ServiceProtocol.JSON,
diff --git a/src/main/java/io/github/hectorvent/floci/services/ram/RamController.java b/src/main/java/io/github/hectorvent/floci/services/ram/RamController.java
new file mode 100644
index 0000000000..493a6b48f3
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/ram/RamController.java
@@ -0,0 +1,336 @@
+package io.github.hectorvent.floci.services.ram;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.services.ram.model.PrincipalAssociation;
+import io.github.hectorvent.floci.services.ram.model.ResourceShare;
+import io.github.hectorvent.floci.services.ram.model.SharedResource;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * AWS Resource Access Manager (Smithy restJson1).
+ *
+ *
Serves the RAM calls AWS Landing Zone Accelerator makes: the organization-sharing opt-in
+ * plus the share reads of the Custom::GetResourceShare / Custom::GetResourceShareItem Lambdas.
+ * The literal paths take JAX-RS precedence over S3's {@code /{bucket}} template route, so no
+ * extra routing wiring is needed — but any RAM path missing here falls through to S3 and
+ * produces an XML error a restJson1 client cannot parse.
+ */
+@Path("/")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class RamController {
+
+ private final RamService service;
+ private final ObjectMapper objectMapper;
+ private final ObjectReader requestReader;
+ private final RegionResolver regionResolver;
+
+ @Inject
+ public RamController(RamService service, ObjectMapper objectMapper, RegionResolver regionResolver) {
+ this.service = service;
+ this.objectMapper = objectMapper;
+ this.requestReader = objectMapper.reader()
+ .with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
+ this.regionResolver = regionResolver;
+ }
+
+ @POST
+ @Path("/enablesharingwithawsorganization")
+ @Consumes(MediaType.WILDCARD)
+ public Response enableSharingWithAwsOrganization() {
+ ObjectNode response = objectMapper.createObjectNode();
+ response.put("returnValue", service.enableSharingWithAwsOrganization());
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/createresourceshare")
+ @Consumes(MediaType.WILDCARD)
+ public Response createResourceShare(@Context HttpHeaders headers, String body) {
+ JsonNode request = readTree(body);
+ String name = request.path("name").asText();
+ boolean allowExternalPrincipals = request.path("allowExternalPrincipals").asBoolean(false);
+ ResourceShare share = service.createResourceShare(
+ name,
+ stringList(request.path("principals")),
+ stringList(request.path("resourceArns")),
+ allowExternalPrincipals,
+ regionResolver.resolveRegion(headers),
+ regionResolver.getAccountId());
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("resourceShare", shareNode(share));
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/getresourceshares")
+ @Consumes(MediaType.WILDCARD)
+ public Response getResourceShares(String body) {
+ JsonNode request = readTree(body);
+ String resourceOwner = request.hasNonNull("resourceOwner")
+ ? request.path("resourceOwner").asText() : null;
+ List shares = service.getResourceShares(
+ regionResolver.getAccountId(),
+ resourceOwner,
+ request.hasNonNull("name") ? request.path("name").asText() : null,
+ stringList(request.path("resourceShareArns")),
+ request.hasNonNull("resourceShareStatus")
+ ? request.path("resourceShareStatus").asText() : null);
+
+ ObjectNode response = objectMapper.createObjectNode();
+ ArrayNode array = objectMapper.createArrayNode();
+ shares.forEach(share -> array.add(shareNode(share)));
+ response.set("resourceShares", array);
+ return Response.ok(response).build();
+ }
+
+ @DELETE
+ @Path("/deleteresourceshare")
+ @Consumes(MediaType.WILDCARD)
+ public Response deleteResourceShare(@QueryParam("resourceShareArn") String resourceShareArn,
+ @QueryParam("clientToken") String clientToken) {
+ service.deleteResourceShare(resourceShareArn, regionResolver.getAccountId());
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.put("returnValue", true);
+ // The response models clientToken; AWS echoes what the caller sent so a retry can be
+ // correlated with the original request.
+ if (clientToken != null) {
+ response.put("clientToken", clientToken);
+ }
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/updateresourceshare")
+ @Consumes(MediaType.WILDCARD)
+ public Response updateResourceShare(String body) {
+ JsonNode request = readTree(body);
+ ResourceShare updated = service.updateResourceShare(
+ request.path("resourceShareArn").asText(),
+ request.hasNonNull("name") ? request.path("name").asText() : null,
+ request.hasNonNull("allowExternalPrincipals")
+ ? request.path("allowExternalPrincipals").asBoolean() : null,
+ regionResolver.getAccountId());
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("resourceShare", shareNode(updated));
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/associateresourceshare")
+ @Consumes(MediaType.WILDCARD)
+ public Response associateResourceShare(String body) {
+ JsonNode request = readTree(body);
+ String resourceShareArn = request.path("resourceShareArn").asText();
+ List resourceArns = stringList(request.path("resourceArns"));
+ List principals = stringList(request.path("principals"));
+ ResourceShare updated = service.associateResourceShare(
+ resourceShareArn, resourceArns, principals, regionResolver.getAccountId());
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("resourceShareAssociations",
+ associationArray(updated, resourceArns, principals, "ASSOCIATED"));
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/disassociateresourceshare")
+ @Consumes(MediaType.WILDCARD)
+ public Response disassociateResourceShare(String body) {
+ JsonNode request = readTree(body);
+ String resourceShareArn = request.path("resourceShareArn").asText();
+ List resourceArns = stringList(request.path("resourceArns"));
+ List principals = stringList(request.path("principals"));
+ ResourceShare updated = service.disassociateResourceShare(
+ resourceShareArn, resourceArns, principals, regionResolver.getAccountId());
+
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("resourceShareAssociations",
+ associationArray(updated, resourceArns, principals, "DISASSOCIATED"));
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/listprincipals")
+ @Consumes(MediaType.WILDCARD)
+ public Response listPrincipals(String body) {
+ JsonNode request = readTree(body);
+ String resourceOwner = request.hasNonNull("resourceOwner")
+ ? request.path("resourceOwner").asText() : null;
+ List principals = service.listPrincipals(
+ regionResolver.getAccountId(), resourceOwner, stringList(request.path("resourceShareArns")));
+
+ ObjectNode response = objectMapper.createObjectNode();
+ ArrayNode array = objectMapper.createArrayNode();
+ for (PrincipalAssociation principal : principals) {
+ ObjectNode node = objectMapper.createObjectNode();
+ node.put("id", principal.id());
+ node.put("resourceShareArn", principal.resourceShareArn());
+ node.put("creationTime", principal.creationTime().toEpochMilli() / 1000.0);
+ node.put("lastUpdatedTime", principal.lastUpdatedTime().toEpochMilli() / 1000.0);
+ node.put("external", principal.external());
+ array.add(node);
+ }
+ response.set("principals", array);
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/tagresource")
+ @Consumes(MediaType.WILDCARD)
+ public Response tagResource(String body) {
+ JsonNode request = readTree(body);
+ Map tags = new LinkedHashMap<>();
+ request.path("tags").forEach(tag -> tags.put(tag.path("key").asText(), tag.path("value").asText()));
+ service.tagResource(request.path("resourceShareArn").asText(), tags,
+ regionResolver.getAccountId());
+ return Response.ok(objectMapper.createObjectNode()).build();
+ }
+
+ @POST
+ @Path("/untagresource")
+ @Consumes(MediaType.WILDCARD)
+ public Response untagResource(String body) {
+ JsonNode request = readTree(body);
+ service.untagResource(request.path("resourceShareArn").asText(),
+ stringList(request.path("tagKeys")), regionResolver.getAccountId());
+ return Response.ok(objectMapper.createObjectNode()).build();
+ }
+
+ @POST
+ @Path("/getresourceshareinvitations")
+ @Consumes(MediaType.WILDCARD)
+ public Response getResourceShareInvitations(String body) {
+ // The body is semantically ignored (invitations are always empty under
+ // organization sharing) but malformed JSON is still a client error.
+ readTree(body);
+ ObjectNode response = objectMapper.createObjectNode();
+ response.set("resourceShareInvitations", objectMapper.createArrayNode());
+ return Response.ok(response).build();
+ }
+
+ @POST
+ @Path("/listresources")
+ @Consumes(MediaType.WILDCARD)
+ public Response listResources(String body) {
+ JsonNode request = readTree(body);
+ String resourceOwner = request.hasNonNull("resourceOwner")
+ ? request.path("resourceOwner").asText() : null;
+ List resources = service.listResources(
+ regionResolver.getAccountId(), resourceOwner, stringList(request.path("resourceShareArns")));
+
+ ObjectNode response = objectMapper.createObjectNode();
+ ArrayNode array = objectMapper.createArrayNode();
+ for (SharedResource resource : resources) {
+ ObjectNode node = objectMapper.createObjectNode();
+ node.put("arn", resource.arn());
+ node.put("type", resource.type());
+ node.put("resourceShareArn", resource.resourceShareArn());
+ node.put("status", resource.status());
+ array.add(node);
+ }
+ response.set("resources", array);
+ return Response.ok(response).build();
+ }
+
+ private ObjectNode shareNode(ResourceShare share) {
+ ObjectNode node = objectMapper.createObjectNode();
+ node.put("resourceShareArn", share.getResourceShareArn());
+ node.put("name", share.getName());
+ node.put("owningAccountId", share.getOwningAccountId());
+ node.put("allowExternalPrincipals", share.isAllowExternalPrincipals());
+ node.put("status", share.getStatus());
+ // Shares created through the API are STANDARD; CREATED_FROM_POLICY covers shares RAM
+ // derives from a resource policy, which floci has no path to produce.
+ node.put("featureSet", "STANDARD");
+ node.put("creationTime", share.getCreationTime().toEpochMilli() / 1000.0);
+ node.put("lastUpdatedTime", share.getLastUpdatedTime().toEpochMilli() / 1000.0);
+ ArrayNode tags = objectMapper.createArrayNode();
+ share.getTags().forEach((key, value) -> {
+ ObjectNode tag = objectMapper.createObjectNode();
+ tag.put("key", key);
+ tag.put("value", value);
+ tags.add(tag);
+ });
+ node.set("tags", tags);
+ return node;
+ }
+
+ /** One row per associated/disassociated resourceArn and principal, per the real RAM shape. */
+ private ArrayNode associationArray(ResourceShare share, List resourceArns,
+ List principals, String status) {
+ ArrayNode array = objectMapper.createArrayNode();
+ double now = share.getLastUpdatedTime().toEpochMilli() / 1000.0;
+ for (String resourceArn : resourceArns) {
+ array.add(associationNode(share, resourceArn, "RESOURCE", status, now));
+ }
+ for (String principal : principals) {
+ array.add(associationNode(share, principal, "PRINCIPAL", status, now));
+ }
+ return array;
+ }
+
+ private ObjectNode associationNode(ResourceShare share, String associatedEntity,
+ String associationType, String status, double time) {
+ ObjectNode node = objectMapper.createObjectNode();
+ node.put("resourceShareArn", share.getResourceShareArn());
+ node.put("resourceShareName", share.getName());
+ node.put("associatedEntity", associatedEntity);
+ node.put("associationType", associationType);
+ node.put("status", status);
+ node.put("creationTime", time);
+ node.put("lastUpdatedTime", time);
+ node.put("external", false);
+ return node;
+ }
+
+ /**
+ * A body that is not valid JSON is a client error: restJson1 rejects it with 400
+ * SerializationException. Left as an UncheckedIOException it escapes to Quarkus'
+ * generic handler and the SDK sees a 500 InternalFailure instead.
+ */
+ private JsonNode readTree(String body) {
+ try {
+ return (body == null || body.isBlank())
+ ? objectMapper.createObjectNode()
+ // Strict: Jackson's default stops at the first complete value, so
+ // "{} not-json" would parse as an empty object and the request would run.
+ : requestReader.readTree(body);
+ } catch (IOException e) {
+ throw new AwsException("SerializationException",
+ "The request could not be parsed as valid JSON.", 400);
+ }
+ }
+
+ private static List stringList(JsonNode node) {
+ List values = new ArrayList<>();
+ node.forEach(n -> values.add(n.asText()));
+ return values;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/ram/RamService.java b/src/main/java/io/github/hectorvent/floci/services/ram/RamService.java
new file mode 100644
index 0000000000..965e8e79aa
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/ram/RamService.java
@@ -0,0 +1,343 @@
+package io.github.hectorvent.floci.services.ram;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.ram.model.PrincipalAssociation;
+import io.github.hectorvent.floci.services.ram.model.ResourceShare;
+import io.github.hectorvent.floci.services.ram.model.SharedResource;
+import jakarta.annotation.PostConstruct;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+
+/**
+ * AWS Resource Access Manager (RAM) business logic.
+ *
+ *
Covers {@code EnableSharingWithAwsOrganization} plus the resource-share reads LZA's
+ * TGW share flow performs: the owning account registers a share (from the
+ * {@code AWS::RAM::ResourceShare} CFN provisioner), and accepting accounts page
+ * GetResourceShareInvitations (always empty here — organization sharing auto-accepts, matching
+ * real AWS), find the share via GetResourceShares(OTHER-ACCOUNTS), and read the shared ARNs via
+ * ListResources.
+ *
+ *
Principals are stored but not enforced for visibility: floci's org is the only org, and
+ * launched containers call in with placeholder credentials that resolve to the default account,
+ * so OTHER-ACCOUNTS simply means "every share the caller does not own". Mutations are the
+ * opposite: they are owner-only, and a non-owner gets the same UnknownResourceException a
+ * never-created ARN gets.
+ */
+@ApplicationScoped
+public class RamService {
+
+ private static final String ORGANIZATION_SHARING_KEY = "sharing-with-organization-enabled";
+ /** The modeled ResourceShareStatus enum. */
+ private static final List SHARE_STATUSES =
+ List.of("PENDING", "ACTIVE", "FAILED", "DELETING", "DELETED");
+
+ private final StorageFactory storageFactory;
+ private StorageBackend shares;
+ private StorageBackend settings;
+
+ @Inject
+ public RamService(StorageFactory storageFactory) {
+ this.storageFactory = storageFactory;
+ }
+
+ @PostConstruct
+ void initializeStorage() {
+ shares = storageFactory.create("ram", "ram-resource-shares.json",
+ new TypeReference