diff --git a/README.md b/README.md
index 5c54561870..65be67b003 100644
--- a/README.md
+++ b/README.md
@@ -238,7 +238,7 @@ Floci supports local emulation for application services, data services, eventing
| Data, analytics, and AI | Athena, Glue, Lake Formation, EMR, EMR Serverless, Redshift, Redshift Data API, Firehose, Managed Service for Apache Flink, OpenSearch, S3 Tables, S3 Vectors, Textract, Transcribe, Comprehend, Rekognition, Translate, 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, Amazon Connect |
-| Security and governance | AWS Network Firewall, AWS RAM, Service Quotas, WAF v2, GuardDuty, Amazon Inspector, CloudTrail, CloudFront, Resource Groups Tagging API, Resource Explorer 2, CloudHSM v2, Organizations, AWS Account Management, IAM Access Analyzer, IAM Identity Center (SSO Admin), Identity Store, Amazon Macie, Amazon Detective, Security Hub, Control Catalog, Control Tower, Service Catalog |
+| Security and governance | AWS Network Firewall, AWS RAM, Service Quotas, WAF v2, GuardDuty, Amazon Inspector, CloudTrail, CloudFront, Resource Groups Tagging API, Resource Explorer 2, CloudHSM v2, Organizations, AWS Account Management, IAM Access Analyzer, IAM Identity Center (SSO Admin), Identity Store, Amazon Macie, Amazon Detective, Security Hub, Control Catalog, Control Tower, Service Catalog, AWS Marketplace |
| Cost and billing | AWS Budgets, 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 |
diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml
index 2bfd4de58f..a52548491d 100644
--- a/compatibility-tests/sdk-test-java/pom.xml
+++ b/compatibility-tests/sdk-test-java/pom.xml
@@ -282,6 +282,11 @@
software.amazon.awssdk
controlcatalog
+
+
+ software.amazon.awssdk
+ marketplacecatalog
+
software.amazon.awssdk
diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
index e8100396e4..1683c82860 100644
--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
@@ -38,6 +38,7 @@ import software.amazon.awssdk.services.identitystore.IdentitystoreClient;
import software.amazon.awssdk.services.budgets.BudgetsClient;
import software.amazon.awssdk.services.macie2.Macie2Client;
import software.amazon.awssdk.services.controlcatalog.ControlCatalogClient;
+import software.amazon.awssdk.services.marketplacecatalog.MarketplaceCatalogClient;
import software.amazon.awssdk.services.inspector2.Inspector2Client;
import software.amazon.awssdk.services.securityhub.SecurityHubClient;
import software.amazon.awssdk.services.detective.DetectiveClient;
@@ -359,6 +360,14 @@ public final class TestFixtures {
.build();
}
+ public static MarketplaceCatalogClient marketplaceCatalogClient() {
+ return MarketplaceCatalogClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
+
public static DetectiveClient detectiveClient(String accountId) {
return DetectiveClient.builder()
.endpointOverride(ENDPOINT)
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java
new file mode 100644
index 0000000000..002147a44f
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/MarketplaceCatalogTest.java
@@ -0,0 +1,17 @@
+package com.floci.test;
+
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.marketplacecatalog.MarketplaceCatalogClient;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class MarketplaceCatalogTest {
+
+ @Test
+ void usesAwsSdkWireContract() {
+ try (MarketplaceCatalogClient client = TestFixtures.marketplaceCatalogClient()) {
+ var response = client.listEntities(r -> r.catalog("AWSMarketplace").entityType("SaaSProduct"));
+ assertNotNull(response.entitySummaryList());
+ }
+ }
+}
diff --git a/docs/services/index.md b/docs/services/index.md
index a68e87f82b..b5d2e020d2 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -104,6 +104,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [AWS Budgets](budgets.md) | `POST /` + `X-Amz-Target: AWSBudgetServiceGateway.*` | JSON 1.1 | 26 |
| [AWS RAM](ram.md) | `POST /{operationname}` (lowercase), `DELETE /deleteresourceshare` | REST JSON | 12 |
| [Control Catalog](controlcatalog.md) | `/get-control`, `/list-controls` | REST JSON | 2 |
+| [AWS Marketplace](marketplace.md) | Marketplace Catalog API | REST JSON | 15 |
| [Control Tower](controltower.md) | `/list-landingzones`, `/get-landingzone`, `/create-landingzone`, `/*-baseline*` | REST JSON | 15 |
| [Managed Prometheus (AMP)](managed-prometheus.md) | `/workspaces/*`, `/workspaces/*/rulegroupsnamespaces/*`, `/tags/*` | REST JSON | 13 |
| [AWS Backup](backup.md) | `/backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 20 |
diff --git a/docs/services/marketplace.md b/docs/services/marketplace.md
new file mode 100644
index 0000000000..87000f5605
--- /dev/null
+++ b/docs/services/marketplace.md
@@ -0,0 +1,35 @@
+# AWS Marketplace
+
+Floci emulates AWS Marketplace APIs under the shared `aws-marketplace` SigV4 signing scope.
+
+## Marketplace Catalog
+
+
+| Action | Description |
+| --- | --- |
+| `BatchDescribeEntities` | Describes up to 20 catalog entities in one request |
+| `CancelChangeSet` | Cancels a change set while it is preparing or applying |
+| `DeleteResourcePolicy` | Deletes an entity resource policy |
+| `DescribeAssessment` | Returns an assessment and control results |
+| `DescribeChangeSet` | Returns change set status and change details |
+| `DescribeEntity` | Returns the current entity revision |
+| `GetResourcePolicy` | Returns an entity resource policy |
+| `ListAssessments` | Lists Marketplace Catalog assessments |
+| `ListChangeSets` | Lists change sets with pagination |
+| `ListEntities` | Lists catalog entities by entity type |
+| `ListTagsForResource` | Lists tags on a Marketplace Catalog resource |
+| `PutResourcePolicy` | Creates or replaces an entity resource policy |
+| `StartChangeSet` | Starts an idempotent Marketplace Catalog change set |
+| `TagResource` | Adds or replaces tags on a Marketplace Catalog resource |
+| `UntagResource` | Removes tag keys from a Marketplace Catalog resource |
+
+
+Catalog change sets use AWS states (`PREPARING`, `APPLYING`, `SUCCEEDED`, and `CANCELLED`). Floci applies supported entity mutations locally when a change set is observed and persists entities, change sets, tags, resource policies, and assessments through `StorageFactory`, isolated by AWS account.
+
+## Configuration
+
+| Variable | Default | Description |
+|---|---|---|
+| `FLOCI_SERVICES_MARKETPLACE_ENABLED` | `true` | Enable or disable AWS Marketplace emulation |
+
+See the [AWS Marketplace API Reference](https://docs.aws.amazon.com/marketplace/latest/APIReference/).
diff --git a/mkdocs.yml b/mkdocs.yml
index b9649a8e3e..7984c68d59 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -129,6 +129,7 @@ nav:
- Security Hub: services/securityhub.md
- Amazon Detective: services/detective.md
- Control Catalog: services/controlcatalog.md
+ - AWS Marketplace: services/marketplace.md
- Control Tower: services/controltower.md
- AWS Service Catalog: services/service-catalog.md
- ElastiCache: services/elasticache.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 d52b27158d..926d7613d6 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -744,6 +744,7 @@ public interface EmulatorConfig {
LakeFormationServiceConfig lakeformation();
EfsServiceConfig efs();
CodeGuruReviewerServiceConfig codegurureviewer();
+ MarketplaceServiceConfig marketplace();
}
interface ConnectServiceConfig {
@@ -811,6 +812,11 @@ public interface EmulatorConfig {
boolean enabled();
}
+ interface MarketplaceServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
interface IotServiceConfig {
@WithDefault("true")
boolean enabled();
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 fb34ca119c..4b1e9e1153 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
@@ -49,6 +49,7 @@ import io.github.hectorvent.floci.services.rum.RumController;
import io.github.hectorvent.floci.services.s3vectors.S3VectorsController;
import io.github.hectorvent.floci.services.s3tables.S3TablesController;
import io.github.hectorvent.floci.services.efs.EfsController;
+import io.github.hectorvent.floci.services.marketplace.MarketplaceCatalogController;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -640,7 +641,12 @@ public class ResolvedServiceCatalog {
"codegurureviewer", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
protocols(ServiceProtocol.REST_JSON),
Set.of(), Set.of("codeguru-reviewer"), Set.of(),
- Set.of(io.github.hectorvent.floci.services.codegurureviewer.CodeGuruReviewerController.class))
+ Set.of(io.github.hectorvent.floci.services.codegurureviewer.CodeGuruReviewerController.class)),
+ descriptor("marketplace", "marketplace", config.services().marketplace().enabled(), true,
+ "marketplace", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
+ protocols(ServiceProtocol.REST_JSON),
+ Set.of(), Set.of("aws-marketplace"), Set.of(),
+ Set.of(MarketplaceCatalogController.class))
));
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceCatalogController.java b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceCatalogController.java
new file mode 100644
index 0000000000..f1818bd17b
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceCatalogController.java
@@ -0,0 +1,151 @@
+package io.github.hectorvent.floci.services.marketplace;
+
+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 io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.RequestContext;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.PATCH;
+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.MediaType;
+import jakarta.ws.rs.core.Response;
+
+@Path("/")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class MarketplaceCatalogController {
+ private final MarketplaceService service;
+ private final ObjectReader strictReader;
+ private final RequestContext context;
+
+ @Inject
+ public MarketplaceCatalogController(MarketplaceService service, ObjectMapper mapper, RequestContext context) {
+ this.service = service;
+ this.strictReader = mapper.reader().with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
+ this.context = context;
+ }
+
+ @POST
+ @Path("/BatchDescribeEntities")
+ public Response batchDescribeEntities(String body) {
+ return ok(service.batchDescribeEntities(parse(body), region()));
+ }
+
+ @PATCH
+ @Path("/CancelChangeSet")
+ public Response cancelChangeSet(@QueryParam("catalog") String catalog, @QueryParam("changeSetId") String id) {
+ return ok(service.cancelChangeSet(catalog, id, region()));
+ }
+
+ @DELETE
+ @Path("/DeleteResourcePolicy")
+ public Response deleteResourcePolicy(@QueryParam("resourceArn") String arn) {
+ return ok(service.deleteResourcePolicy(arn, region()));
+ }
+
+ @POST
+ @Path("/DescribeAssessment")
+ public Response describeAssessment(String body) {
+ return ok(service.describeAssessment(parse(body), region()));
+ }
+
+ @GET
+ @Path("/DescribeChangeSet")
+ public Response describeChangeSet(@QueryParam("catalog") String catalog, @QueryParam("changeSetId") String id) {
+ return ok(service.describeChangeSet(catalog, id, region()));
+ }
+
+ @GET
+ @Path("/DescribeEntity")
+ public Response describeEntity(@QueryParam("catalog") String catalog, @QueryParam("entityId") String id) {
+ return ok(service.describeEntity(catalog, id, region()));
+ }
+
+ @GET
+ @Path("/GetResourcePolicy")
+ public Response getResourcePolicy(@QueryParam("resourceArn") String arn) {
+ return ok(service.getResourcePolicy(arn, region()));
+ }
+
+ @POST
+ @Path("/ListAssessments")
+ public Response listAssessments(String body) {
+ return ok(service.listAssessments(parse(body), region()));
+ }
+
+ @POST
+ @Path("/ListChangeSets")
+ public Response listChangeSets(String body) {
+ return ok(service.listChangeSets(parse(body), region()));
+ }
+
+ @POST
+ @Path("/ListEntities")
+ public Response listEntities(String body) {
+ return ok(service.listEntities(parse(body), region()));
+ }
+
+ @POST
+ @Path("/ListTagsForResource")
+ public Response listTagsForResource(String body) {
+ return ok(service.catalogListTags(parse(body), region()));
+ }
+
+ @POST
+ @Path("/PutResourcePolicy")
+ public Response putResourcePolicy(String body) {
+ return ok(service.putResourcePolicy(parse(body), region()));
+ }
+
+ @POST
+ @Path("/StartChangeSet")
+ public Response startChangeSet(String body) {
+ return ok(service.startChangeSet(parse(body), region()));
+ }
+
+ @POST
+ @Path("/TagResource")
+ public Response tagResource(String body) {
+ return ok(service.catalogTagResource(parse(body), region()));
+ }
+
+ @POST
+ @Path("/UntagResource")
+ public Response untagResource(String body) {
+ return ok(service.catalogUntagResource(parse(body), region()));
+ }
+
+ private JsonNode parse(String body) {
+ try {
+ JsonNode value = strictReader.readTree(body == null || body.isBlank() ? "{}" : body);
+ if (value == null || !value.isObject()) {
+ throw validation("Request body must be a JSON object.");
+ }
+ return value;
+ } catch (AwsException e) {
+ throw e;
+ } catch (Exception e) {
+ throw validation("Request body is not valid JSON.");
+ }
+ }
+
+ private String region() {
+ return context.getRegion() == null ? "us-east-1" : context.getRegion();
+ }
+
+ private static Response ok(JsonNode node) {
+ return Response.ok(node).build();
+ }
+
+ private static AwsException validation(String message) {
+ return new AwsException("ValidationException", message, 422);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceService.java b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceService.java
new file mode 100644
index 0000000000..62ccab9952
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceService.java
@@ -0,0 +1,850 @@
+package io.github.hectorvent.floci.services.marketplace;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+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.RequestContext;
+import io.github.hectorvent.floci.core.common.Resettable;
+import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.marketplace.model.MarketplaceChangeSetRequest;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.time.Instant;
+import java.time.format.DateTimeParseException;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+@ApplicationScoped
+public class MarketplaceService implements Resettable {
+ private static final String CATALOG = "AWSMarketplace";
+ private static final String REGION = "us-east-1";
+ private static final Pattern CLIENT_TOKEN = Pattern.compile("[!-~]{1,64}");
+ private static final Pattern CHANGE_SET_NAME = Pattern.compile("[\\w\\s+=.:@-]{1,100}");
+ private static final Set SUPPORTED_CHANGE_TYPES = Set.of(
+ "AddDeliveryOptions", "AddDimension", "AddDimensions", "AddInstanceTypes", "AddRegions",
+ "AddRepositories", "AddRevisions", "AllowProductProcurement", "AssociateAudience",
+ "AssociateOffers", "AssociateSolution", "CreateBrandingSettings", "CreateExperience",
+ "CreateOffer", "CreateOfferSet", "CreateOfferUsingResaleAuthorization", "CreateProcurementPolicy",
+ "CreateProduct", "CreateReplacementOffer", "CreateReplacementOfferUsingResaleAuthorization",
+ "CreateResaleAuthorization", "CreateSolution", "DenyProductProcurement", "DisassociateAudience",
+ "DisassociateOffers", "DisassociateSolution", "ReleaseOffer", "ReleaseOfferSet", "ReleaseProduct",
+ "ReleaseResaleAuthorization", "ReleaseSolution", "RestrictDeliveryOptions", "RestrictDimension",
+ "RestrictExperience", "RestrictInstanceTypes", "RestrictRegions", "RestrictResaleAuthorization",
+ "ReviveExperience", "UpdateAvailability", "UpdateBrandingSettings", "UpdateBuyerEngagementOptions",
+ "UpdateBuyerTargetingTerms", "UpdateBuyerValidityTerms", "UpdateCustomerVerificationTerms",
+ "UpdateDeliveryOptions", "UpdateDeliveryOptionsVisibility", "UpdateDimension", "UpdateExperience",
+ "UpdateFutureRegionSupport", "UpdateInformation", "UpdateLegalTerms", "UpdateMarkup",
+ "UpdatePaymentScheduleTerms", "UpdatePricingTerms", "UpdateProcurementPolicy", "UpdateRelatedProducts",
+ "UpdateRenewalTerms", "UpdateSupportTerms", "UpdateTargeting", "UpdateValidityTerms", "UpdateVisibility");
+ private static final Logger LOG = Logger.getLogger(MarketplaceService.class);
+
+ private final ObjectMapper mapper;
+ private final AccountAwareStorageBackend entities;
+ private final AccountAwareStorageBackend changeSets;
+ private final AccountAwareStorageBackend resourcePolicies;
+ private final AccountAwareStorageBackend tags;
+ private final AccountAwareStorageBackend assessments;
+ private final RequestContext requestContext;
+
+ @Inject
+ public MarketplaceService(StorageFactory factory, ObjectMapper mapper, RequestContext requestContext) {
+ this(mapper,
+ factory.create("marketplace", "marketplace-entities.json", type()),
+ factory.create("marketplace", "marketplace-change-sets.json", type()),
+ factory.create("marketplace", "marketplace-resource-policies.json", type()),
+ factory.create("marketplace", "marketplace-tags.json", type()),
+ factory.create("marketplace", "marketplace-assessments.json", type()),
+ requestContext);
+ }
+
+ MarketplaceService(ObjectMapper mapper,
+ AccountAwareStorageBackend entities,
+ AccountAwareStorageBackend changeSets,
+ AccountAwareStorageBackend resourcePolicies,
+ AccountAwareStorageBackend tags,
+ AccountAwareStorageBackend assessments,
+ RequestContext requestContext) {
+ this.mapper = mapper;
+ this.entities = entities;
+ this.changeSets = changeSets;
+ this.resourcePolicies = resourcePolicies;
+ this.tags = tags;
+ this.assessments = assessments;
+ this.requestContext = requestContext;
+ }
+
+ private static TypeReference