fix(cognito): refuse user pool custom domains in the China Regions (#9644)

This commit is contained in:
Hector Ventura authored and GitHub committed 2026-11-28 08:27:25 -04:00
1 parent 28d6d2997f
commit e20b3ff8dc
4 files changed
+30 -29

No files matched your search

+6 -2
View File
@@ -147,11 +147,15 @@ a colon in that setting. Existing stored namespaces are not migrated or deleted
[GovCloud](https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-lambda.html) and
[China](https://docs.amazonaws.cn/en_us/aws/latest/userguide/lambda.html) guides list function URLs
as not available.
A Cognito user pool custom domain (`CustomDomainConfig`) is refused in GovCloud and EUSC
A Cognito user pool custom domain (`CustomDomainConfig`) is refused in GovCloud, EUSC and China
(`InvalidParameterException`), where the
[GovCloud](https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-cog.html) and
[EUSC](https://docs.aws.eu/esc/latest/userguide/cognito.html) guides list custom domains as not
available; prefix domains work there.
available, and the China guides list user pools as not available
([Cognito](https://docs.amazonaws.cn/en_us/aws/latest/userguide/cognito.html)) and CloudFront as
not taking ACM certificates
([CloudFront](https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html)); prefix
domains work there.
- **VPC endpoint service names**: interface endpoints (as `DescribeVpcEndpointServices` lists them)
are `com.amazonaws.<region>.<service>` everywhere, except the (region, service) pairs the CDK
lists for China, ISO and EUSC, which reverse the DNS suffix (`cn.com.amazonaws.cn-north-1.lambda`).
+8 -4
View File
@@ -241,11 +241,15 @@ certificate as soon as it is created, so `https://<domain>` verifies without a r
`amazoncognito.com` on AWS, not by Floci, and is left alone.
Custom domains are not available in AWS GovCloud (US)
([GovCloud guide](https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-cog.html)) or in
([GovCloud guide](https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-cog.html)), in
the AWS European Sovereign Cloud
([EUSC guide](https://docs.aws.eu/esc/latest/userguide/cognito.html)), so `CreateUserPoolDomain` and
`UpdateUserPoolDomain` refuse a `CustomDomainConfig` in a GovCloud or EUSC region with
`InvalidParameterException`. Prefix domains work there. See
([EUSC guide](https://docs.aws.eu/esc/latest/userguide/cognito.html)) or in the China Regions, where
user pools are not available
([China Cognito guide](https://docs.amazonaws.cn/en_us/aws/latest/userguide/cognito.html)) and
CloudFront does not take ACM certificates
([China CloudFront guide](https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html)). So
`CreateUserPoolDomain` and `UpdateUserPoolDomain` refuse a `CustomDomainConfig` in a GovCloud, EUSC
or China region with `InvalidParameterException`. Prefix domains work there. See
[AWS Partitions](../configuration/partitions.md).
### Log Delivery
@@ -1877,7 +1877,7 @@ public class CognitoService implements ResourceProvider, StoredResourceArns {
private static final String CERTIFICATE_NOT_USABLE = "The specified SSL certificate doesn't exist, "
+ "isn't in us-east-1 region, isn't valid, or doesn't include a valid certificate chain."; // partition-literal: AWS's message text
/** The partitions where AWS documents user pool custom domains as not available. */
private static final Set<String> CUSTOM_DOMAIN_UNAVAILABLE_PARTITIONS = Set.of("aws-us-gov", "aws-eusc");
private static final Set<String> CUSTOM_DOMAIN_UNAVAILABLE_PARTITIONS = Set.of("aws-us-gov", "aws-eusc", "aws-cn");
/**
* Creates either an Amazon Cognito prefix domain ({@code customDomainConfig == null})
@@ -2102,8 +2102,13 @@ public class CognitoService implements ResourceProvider, StoredResourceArns {
* User pool custom domains are not available in AWS GovCloud (US) or in the AWS European
* Sovereign Cloud: both guides say "Custom domains for user pools are not available"
* (https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-cog.html,
* https://docs.aws.eu/esc/latest/userguide/cognito.html). Prefix domains are. No source shows
* AWS's message for the refusal, so the wording is Floci's own.
* https://docs.aws.eu/esc/latest/userguide/cognito.html). Nor in the China Regions, whose guides
* say "Amazon Cognito User Pools are not currently available in the China (Beijing) Region"
* (https://docs.amazonaws.cn/en_us/aws/latest/userguide/cognito.html) and "Amazon CloudFront in
* the China Regions currently does not support Amazon Certificate Manager"
* (https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html), so no ACM certificate
* could front one. Prefix domains are. No source shows AWS's message for the refusal, so the
* wording is Floci's own.
*/
private static void requireCustomDomainsAvailable(String region) {
AwsPartition partition = AwsPartitions.forRegionOrCommercial(region);
@@ -25,9 +25,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoInteractions;
/**
* User pool custom domains are not available in AWS GovCloud (US) or in the AWS European Sovereign
* Cloud, so one cannot be created or configured there, while a prefix domain works in every
* partition that has user pools.
* User pool custom domains are not available in AWS GovCloud (US), the AWS European Sovereign
* Cloud or the China Regions, so one cannot be created or configured there, while a prefix domain
* works in every partition.
*/
@ResourceLock(ParallelLocks.PORTS)
class CognitoCustomDomainPartitionTest {
@@ -59,8 +59,8 @@ class CognitoCustomDomainPartitionTest {
}
@ParameterizedTest
@ValueSource(strings = {"us-gov-west-1", "us-gov-east-1", "eusc-de-east-1"})
void aCustomDomainIsRefusedInGovCloudAndEusc(String region) {
@ValueSource(strings = {"us-gov-west-1", "us-gov-east-1", "eusc-de-east-1", "cn-north-1", "cn-northwest-1"})
void aCustomDomainIsRefusedInGovCloudEuscAndChina(String region) {
CognitoService service = serviceIn(region);
String poolId = createPool(service, region);
@@ -74,8 +74,8 @@ class CognitoCustomDomainPartitionTest {
}
@ParameterizedTest
@ValueSource(strings = {"us-gov-west-1", "us-gov-east-1", "eusc-de-east-1"})
void aPrefixDomainCannotBeGivenACustomDomainConfigInGovCloudOrEusc(String region) {
@ValueSource(strings = {"us-gov-west-1", "us-gov-east-1", "eusc-de-east-1", "cn-north-1"})
void aPrefixDomainCannotBeGivenACustomDomainConfigInGovCloudEuscOrChina(String region) {
CognitoService service = serviceIn(region);
String poolId = createPool(service, region);
service.createUserPoolDomain("only-prefix", poolId, null, null);
@@ -88,7 +88,7 @@ class CognitoCustomDomainPartitionTest {
}
@ParameterizedTest
@ValueSource(strings = {"us-east-1", "us-gov-west-1", "us-gov-east-1", "eusc-de-east-1"})
@ValueSource(strings = {"us-east-1", "us-gov-west-1", "us-gov-east-1", "eusc-de-east-1", "cn-north-1"})
void aPrefixDomainIsAcceptedAndUpdatedInEveryPartition(String region) {
CognitoService service = serviceIn(region);
String poolId = createPool(service, region);
@@ -115,18 +115,6 @@ class CognitoCustomDomainPartitionTest {
assertEquals(replacement.get("CertificateArn"), updated.getCertificateArn());
}
@Test
void aCustomDomainInChinaIsServedFromTheChinaCloudFrontSuffix() {
CognitoService service = serviceIn("cn-north-1");
String poolId = createPool(service, "cn-north-1");
Map<String, Object> certificate =
Map.of("CertificateArn", "arn:aws-cn:acm:us-east-1:" + ACCOUNT + ":certificate/abc");
UserPoolDomain created = service.createUserPoolDomain(CUSTOM_DOMAIN, poolId, certificate, null);
assertThat(created.getCloudFrontDistribution(), matchesPattern("d[0-9a-f]{13}\\.cloudfront\\.cn"));
}
@ParameterizedTest
@ValueSource(strings = {
"arn:aws-cn:acm:us-east-1:000000000000:certificate/abc",