amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

support for custom domains

Open chrisbonifacio opened this issue 1 year ago • 16 comments

Environment information

N/A

Description

I would like to be able to deploy my Gen 2 application to a custom domain

chrisbonifacio avatar Jan 29 '24 16:01 chrisbonifacio

The Amplify Console UI shows it's coming soon Screen Shot 2024-01-29 at 9 39 25 AM

It would be great if there's a CDK-based solution for this as a workaround.

exai-sukh avatar Jan 29 '24 17:01 exai-sukh

you can use

aws amplify create-domain-association --app-id <VALUE> --domain-name <VALUE> --sub-domain-settings prefix=<VALUE>,branchName=<VALUE>

https://docs.aws.amazon.com/cli/latest/reference/amplify/create-domain-association.html

blinkdaffer avatar Jan 29 '24 20:01 blinkdaffer

Command to get your app-id aws amplify list-apps

Command to create custom domain aws amplify create-domain-association --app-id=d1b61z****l79 --domain-name=example.co.uk --sub-domain-settings prefix=,branchName=main

ekpono-globalvoices avatar Jan 31 '24 13:01 ekpono-globalvoices

Custom domain support for Amplify Gen 2 apps is currently in development and is not available as part of the preview. That being said, as stated in this thread you can add custom domains to your Gen 2 apps using the AWS CLI/API/SDK.

To add a custom domain, you can use the create-domain-association API:

aws amplify create-domain-association --app-id <VALUE> --domain-name <VALUE> --sub-domain-settings prefix=<VALUE>,branchName=<VALUE>

To retrieve the required dns records, you can use the get-domain-association API:

aws amplify get-domain-association --app-id <VALUE> --domain-name <VALUE> 

Also, you can add wildcard subdomains on the app by modifying the prefix attribute as follows:

aws amplify create-domain-association --app-id <VALUE> --domain-name <VALUE> --sub-domain-settings prefix=\*,branchName=<VALUE>

Jay2113 avatar Jan 31 '24 20:01 Jay2113

As @Jay2113 called out, Custom domain support in Gen2 is work in progress. We will update this ticket in next few weeks as soon as its released in production. Stay tuned!

Milan-Shah avatar Feb 09 '24 17:02 Milan-Shah

Will be waiting 😏

rajeshrah22 avatar Feb 19 '24 04:02 rajeshrah22

Can't wait for GA. Any tentative date for GA?

ayepRahman avatar Mar 14 '24 14:03 ayepRahman

As @Jay2113 called out, Custom domain support in Gen2 is work in progress. We will update this ticket in next few weeks as soon as its released in production. Stay tuned!

@Milan-Shah What is the approximate release time? I am also trying to deploy my new project with Gen 2, looking forward to the official release.

PlayApple avatar Mar 21 '24 06:03 PlayApple

Thanks @Jay2113 !

How can I create a domain association for the domain apex?

elad-maimon avatar Mar 27 '24 14:03 elad-maimon

any news?

imana97 avatar Apr 12 '24 02:04 imana97

I share my code to create the association via CDK. Maybe it can be helpful for someone who wants to keep tracks

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { aws_amplify as amplify } from 'aws-cdk-lib';

export class AmplifyDomainStack extends cdk.Stack {
    constructor(scope: Construct, id: string, props?: cdk.StackProps) {
        super(scope, id, props);

        const cfnDomain = new amplify.CfnDomain(this, 'WebsiteAmplifyCfnDomain', {
            appId: 'your-app-id',
            domainName: 'domain.com',
            subDomainSettings: [{
                branchName: 'main',
                prefix: '',
            }],
        });
    }
}

dr-star avatar Apr 12 '24 08:04 dr-star

We are getting a 404 accessing our custom domain after creating the association via CDK. The response headers include

X-Cache: Error from cloudfront

jFensch avatar Apr 30 '24 20:04 jFensch

Custom domain feature seems to be live on the console.

ideen1 avatar May 03 '24 08:05 ideen1

Custom domain feature seems to be live on the console.

@ideen1 What region? Is it for new or existing deployment? I'm still seeing 'Coming Soon'

rosswickman avatar May 03 '24 14:05 rosswickman

@rosswickman Oh that is interesting. It may be a gradual rollout. I am seeing this in ca-central-1 on an existing app.

ideen1 avatar May 03 '24 16:05 ideen1

@ideen1 I have it now!!!

rosswickman avatar May 03 '24 19:05 rosswickman

This is now available.

swaminator avatar May 08 '24 08:05 swaminator

Can you provide an example of how to do it via the native amplify CDK

vaughngit avatar May 15 '24 18:05 vaughngit