Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(marketplace): serve Entitlement and Agreement in every region AWS publishes (#5028)

Hector Ventura546b5cef646b
diff --git a/docs/services/marketplace.md b/docs/services/marketplace.md
index e419967130..d68bb04292 100644
--- a/docs/services/marketplace.md
+++ b/docs/services/marketplace.md
@@ -79,6 +79,8 @@ Catalog change sets use AWS states (`PREPARING`, `APPLYING`, `SUCCEEDED`, and `C
Agreement request acceptance persists the resulting agreement and exposes it through subsequent read and search operations. State is isolated by AWS account through `StorageFactory`.
+The API is served in the regions AWS publishes an endpoint for: `us-east-1`, `us-iso-east-1`, `us-isob-east-1`, `us-isof-south-1` and `eusc-de-east-1`. Requests signed for any other region are rejected with a `ValidationException`.
+
### Known deviations
- Accepted agreements use a local 365-day duration instead of deriving the end time from requested terms.
@@ -88,6 +90,8 @@ Agreement request acceptance persists the resulting agreement and exposes it thr
AWS exposes this service as read-only: `GetEntitlements` is the only public operation. Floci therefore does not add a non-AWS mutation endpoint. Entitlement records are loaded from the shared `StorageFactory` backend (`marketplace-entitlements.json` in persistent mode), so tests and local environments can pre-seed AWS-shaped entitlement state while preserving account isolation.
+`GetEntitlements` is served in the regions AWS publishes an endpoint for: `us-east-1`, `cn-northwest-1` and `eusc-de-east-1`. Requests signed for any other region are rejected with an `InvalidParameterException`.
+
## Marketplace Deployment
diff --git a/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementService.java b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementService.java
index 7fade8fcd5..32c7455871 100644
--- a/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementService.java
@@ -25,7 +25,10 @@ import java.util.regex.Pattern;
@ApplicationScoped
public class MarketplaceAgreementService implements Resettable {
- private static final String REGION = "us-east-1"; // partition-literal: AWS Marketplace is commercial-only and AWS pins its APIs to these regions
+ // The regions AWS publishes an Agreement endpoint in, across partitions (botocore endpoints.json).
+ private static final Set<String> REGIONS = Set.of(
+ "us-east-1", "us-iso-east-1", "us-isob-east-1", // partition-literal: AWS's endpoint regions
+ "us-isof-south-1", "eusc-de-east-1"); // partition-literal: AWS's endpoint regions
private static final String CATALOG = "AWSMarketplace";
private static final Pattern PROPOSAL_ID = Pattern.compile("(at-|ap-)[A-Za-z0-9]+");
private static final Pattern CLIENT_TOKEN = Pattern.compile("[a-zA-Z0-9-]{1,64}");
@@ -781,8 +784,10 @@ public class MarketplaceAgreementService implements Resettable {
}
private static void validateRegion(String region) {
- if (!REGION.equals(region)) {
- throw validation("AWS Marketplace Agreement API is available only in us-east-1."); // partition-literal: AWS's message text
+ if (region == null || !REGIONS.contains(region)) {
+ throw validation("AWS Marketplace Agreement API is available only in "
+ + "us-east-1, us-iso-east-1, us-isob-east-1, " // partition-literal: the served regions
+ + "us-isof-south-1, and eusc-de-east-1."); // partition-literal: the served regions
}
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementService.java b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementService.java
index 839a35e2d6..67a3a1fd42 100644
--- a/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementService.java
@@ -22,6 +22,9 @@ import java.util.Set;
@ApplicationScoped
public class MarketplaceEntitlementService implements Resettable {
+ // The regions AWS publishes an Entitlement endpoint in, across partitions (botocore endpoints.json).
+ private static final Set<String> REGIONS = Set.of(
+ "us-east-1", "cn-northwest-1", "eusc-de-east-1"); // partition-literal: AWS's endpoint regions
private static final Set<String> FILTER_KEYS = Set.of(
"CUSTOMER_IDENTIFIER", "DIMENSION", "CUSTOMER_AWS_ACCOUNT_ID", "LICENSE_ARN");
@@ -40,9 +43,11 @@ public class MarketplaceEntitlementService implements Resettable {
}
ObjectNode getEntitlements(JsonNode request, String region) {
- if (region != null && !region.isBlank() && !"us-east-1".equals(region)) { // partition-literal: AWS Marketplace is commercial-only and AWS pins its APIs to these regions
+ if (region != null && !region.isBlank() && !REGIONS.contains(region)) {
throw new AwsException("InvalidParameterException",
- "AWS Marketplace Entitlement Service is available only in us-east-1.", 400); // partition-literal: AWS's message text
+ "AWS Marketplace Entitlement Service is available only in "
+ + "us-east-1, cn-northwest-1, " // partition-literal: the served regions
+ + "and eusc-de-east-1.", 400); // partition-literal: the served regions
}
String productCode = requireText(request, "ProductCode", 1, 255);
JsonNode filter = request == null ? null : request.get("Filter");
diff --git a/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementServiceTest.java
index daf79340d0..2e6b375243 100644
--- a/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceAgreementServiceTest.java
@@ -146,4 +146,19 @@ class MarketplaceAgreementServiceTest {
() -> service.handle("SearchAgreements", mapper.readTree("{\"filters\":[{\"name\":\"AgreementType\",\"values\":[\"PurchaseAgreement\"]}]}"), "us-west-2"));
assertEquals("ValidationException", error.getErrorCode());
}
+
+ @Test
+ void searchAgreementsIsServedInEveryRegionAwsPublishesOutsideCommercial() throws Exception {
+ JsonNode request = mapper.readTree(
+ "{\"filters\":[{\"name\":\"AgreementType\",\"values\":[\"PurchaseAgreement\"]}]}");
+ for (String region : new String[] {"eusc-de-east-1", "us-iso-east-1", "us-isob-east-1", "us-isof-south-1"}) {
+ JsonNode response = service.handle("SearchAgreements", request, region);
+ assertEquals(0, response.path("agreementViewSummaries").size(), region);
+ }
+ AwsException error = assertThrows(AwsException.class,
+ () -> service.handle("SearchAgreements", request, "cn-north-1"));
+ assertEquals("ValidationException", error.getErrorCode());
+ assertEquals("AWS Marketplace Agreement API is available only in us-east-1, us-iso-east-1, us-isob-east-1, "
+ + "us-isof-south-1, and eusc-de-east-1.", error.getMessage());
+ }
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementServiceTest.java
index 896199f2d7..b6b3f6cd5d 100644
--- a/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/marketplace/MarketplaceEntitlementServiceTest.java
@@ -65,4 +65,19 @@ class MarketplaceEntitlementServiceTest {
assertThrows(AwsException.class,
() -> service.getEntitlements(mapper.readTree("{\"ProductCode\":\"product-local\"}"), "us-west-2"));
}
+
+ @Test
+ void getEntitlementsIsServedInEveryRegionAwsPublishesOutsideCommercial() throws Exception {
+ for (String region : new String[] {"cn-northwest-1", "eusc-de-east-1"}) {
+ JsonNode response = service.getEntitlements(
+ mapper.readTree("{\"ProductCode\":\"product-local\"}"), region);
+ assertEquals(0, response.path("Entitlements").size(), region);
+ }
+ AwsException error = assertThrows(AwsException.class,
+ () -> service.getEntitlements(
+ mapper.readTree("{\"ProductCode\":\"product-local\"}"), "cn-north-1"));
+ assertEquals("InvalidParameterException", error.getErrorCode());
+ assertEquals("AWS Marketplace Entitlement Service is available only in us-east-1, cn-northwest-1, "
+ + "and eusc-de-east-1.", error.getMessage());
+ }
}