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

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

GetEntitlements and the Marketplace Agreement API refused every region but
us-east-1, on the assumption that AWS Marketplace is commercial-only. AWS
publishes more endpoints than that: Entitlement also runs in cn-northwest-1
and eusc-de-east-1, and Agreement in us-iso-east-1, us-isob-east-1,
us-isof-south-1 and eusc-de-east-1 (botocore endpoints.json). Both now accept
exactly those regions and keep refusing the rest with AWS's message and error
code, so cn-north-1, which has neither endpoint, is still rejected.

* fix(marketplace): name the served regions in the Entitlement and Agreement refusals

Both refusals still said "available only in us-east-1" after the region sets
grew, so a caller in an unserved ISO, EUSC or China region was pointed at a
commercial region it cannot reach. Each message now lists the regions its
API serves, as Marketplace Discovery's already does. No reference source
carries AWS's text for these refusals, so the comment no longer calls it
AWS's.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-03 22:04:03 -04:00
1 parent f9a65581be
commit 546b5cef64
5 files changed
+49 -5

No files matched your search

@@ -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
}
}
@@ -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");