Skip to content

Cognito custom domain creation fails with CloudFront CNAMEAlreadyExists (409) despite resource cleanup

0

Problem

We are experiencing an issue when creating Amazon Cognito custom domains using the CreateUserPoolDomain API.

The operation consistently fails with the following error:

InvalidParameterException:
One or more of the CNAMEs you provided are already
associated with a different resource.
(Service: CloudFront, Status Code: 409)

This affects two separate environments, each with its own AWS account, Cognito user pool, and ACM certificate.

The custom domains previously had associations with CloudFront resources, but those customer-managed associations have been removed.

Despite this cleanup, the error persists.

Investigation

We performed the following troubleshooting steps:

  1. CloudFront: Verified that no customer-accessible CloudFront distributions currently have the affected hostnames configured as alternate domain names (CNAMEs).
  2. API Gateway: Confirmed that no REST API or HTTP API custom domains are using these hostnames.
  3. Cognito: Confirmed that describe-user-pool-domain returns an empty object ({}) for both domains, indicating that no matching domain configuration is visible.
  4. Previous CloudFront distributions: Removed the alternate domain names from older customer-managed distributions. The changes have been deployed successfully, and the distributions now have zero aliases.
  5. Duplicate resources: Deleted previously identified duplicate or stale customer-managed resources.
  6. Route 53: Temporarily removed the relevant DNS records to rule out DNS configuration issues. The error persisted.

Potential cause

When inspecting the ACM certificates associated with the custom domains, we found that the InUseBy field still references CloudFront distributions.

These distributions appear to belong to an AWS service-managed account rather than our customer-managed AWS accounts.

We suspect that previous Cognito custom domain configurations may have left behind CloudFront associations that were not fully released.

However, we cannot confirm whether the referenced distributions still own the conflicting CNAMEs, since they are not accessible through our AWS accounts.

Questions

  1. Is it possible for Cognito-managed CloudFront distributions to retain alternate domain name associations after the corresponding Cognito custom domain has been deleted?

  2. Is there a supported self-service method to identify and release stale CloudFront CNAME associations when the associated distribution is AWS service-managed?

  3. Does an ACM certificate's InUseBy field referencing a service-managed CloudFront distribution indicate that the custom domain association is still active, or could this be a separate certificate cleanup issue?

  4. If this requires AWS-side intervention, which service team (Cognito or CloudFront) should handle the issue, and what is the recommended escalation procedure?

Expected behavior

After deleting previous custom domain configurations and removing all customer-managed CloudFront aliases, the affected hostnames should become available for new Cognito custom domain associations.

Instead, CreateUserPoolDomain continues to return HTTP 409 errors.

Has anyone encountered this behavior before? Is there a documented recovery procedure for potentially orphaned Cognito-managed CloudFront associations?

Any guidance would be appreciated.

1 Answer
0

Your evidence does point to a CloudFront distribution in an AWS-owned account that still holds the hostnames. Here's what you can check yourself and how to escalate.

1. Can a Cognito-managed distribution keep the alias after the domain is deleted?

Cognito custom domains are served by a CloudFront distribution in an AWS-managed account. Deleting the domain should eventually remove that distribution and free the alias. Your observations suggest that distribution still exists:

  • ACM InUseBy still lists it.
  • CloudFront reports a CNAME conflict.

Before treating it as orphaned, rule out a live Cognito domain elsewhere. describe-user-pool-domain only checks the region you call it in:

  • Check every region and every account that might have used these hostnames, including old sandbox and dev accounts. A user pool in another region, or another pool in the same account, can still own the domain.
  • Check other services that create AWS-managed CloudFront distributions in all regions and accounts: API Gateway edge-optimized custom domains, AWS Amplify Hosting custom domains, AppSync custom domains, and Lightsail distributions.
  • Check for wildcards. An alias like *.example.com on any distribution can also conflict.

2. Self-service: identify who holds the alias

CloudFront's ListConflictingAliases API is built for this:

  1. In one of the affected accounts, create a temporary CloudFront distribution that uses the existing ACM certificate (in us-east-1) covering the hostname. It doesn't need the alias attached.
  2. Run:
    aws cloudfront list-conflicting-aliases \
      --distribution-id <temp-dist-id> --alias auth.example.com
  3. The response shows the conflicting distribution ID and account ID, partially masked. That's enough to tell whether the holder is one of your accounts or an AWS service account. If it's one of yours, you can move the alias yourself with AssociateAlias.

If the holder is an AWS-managed distribution, you can't release it yourself.

3. What InUseBy tells you

ACM lists the resources currently using the certificate. A service-managed distribution in InUseBy most likely means the distribution still exists and is still bound to the certificate. That's consistent with the alias still being held, not a separate certificate-cleanup issue. When the distribution is deleted, the entry normally disappears. Note that issuing a new certificate won't release the alias.

4. Escalation

The owner of the distribution has to fix this, and here that's Cognito, which manages it. Open a support case under Cognito and ask them to bring in CloudFront if needed. Include:

  • The ListConflictingAliases output (masked IDs are fine)
  • The distribution ARNs from ACM InUseBy
  • The user pool IDs, regions, and dates of the earlier Cognito domains, if you know them
  • The request IDs of the failed CreateUserPoolDomain calls

AWS will likely ask you to prove you own the domain, usually by adding a TXT record they specify, before they release the alias. Have DNS access ready.

EXPERT

answered a month ago

EXPERT

reviewed a month ago

  • We checked auth.uat.phdcompass.net across 17 enabled AWS regions in our management, dev, UAT, and prod accounts, plus the accessible hub account. We found no live Cognito custom domain for it. We also found no matching domain in the other checked services or visible CloudFront distributions.

    A fresh CreateUserPoolDomain attempt in UAT failed with CloudFront 409: “One or more of the CNAMEs you provided are already associated with a different resource.” The underlying CloudFront request ID was dafd0a73-02e6-4ae2-b9c7-90dd95ad9db2.

    We created a temporary disabled CloudFront distribution with the UAT certificate and called ListConflictingAliases. It returned one exact match: auth.uat.phdcompass.net, distribution *******GSG7C2I, account ******493081. ACM’s InUseBy identifies the full reference as arn:aws:cloudfront::455458493081:distribution/E2MSNDMGSG7C2I. The temporary distribution was then deleted. CloudFront documents that this API masks the IDs and reports conflicting aliases. (docs.aws.amazon.com)

    CloudTrail records a successful deletion of the UAT Cognito custom domain from user pool eu-west-1_sylhhANCD on September 1, 2026, at 18:04:03 UTC+02:00 (request ID 91850a2e-82ba-4da1-9791-e8da427fc2fa). Subsequent creation attempts, including this one, have failed with the alias conflict. Please ask Cognito and CloudFront to inves

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.