aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
185 stars 62 forks source link

support for custom domains #954

Closed chrisbonifacio closed 6 months ago

chrisbonifacio commented 9 months ago

Environment information

N/A

Description

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

exai-sukh commented 9 months ago

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.

blinkdaffer commented 9 months ago

you can use

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

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

ekpono-globalvoices commented 9 months ago

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

Jay2113 commented 9 months ago

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>
Milan-Shah commented 9 months ago

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!

rajeshrah22 commented 9 months ago

Will be waiting 😏

ayepRahman commented 8 months ago

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

PlayApple commented 8 months ago

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.

elad-maimon commented 7 months ago

Thanks @Jay2113 !

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

imana97 commented 7 months ago

any news?

dr-star commented 7 months ago

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: '',
            }],
        });
    }
}
jFensch commented 6 months ago

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

X-Cache: Error from cloudfront

ideen1 commented 6 months ago

Custom domain feature seems to be live on the console.

rosswickman commented 6 months ago

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'

ideen1 commented 6 months ago

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

rosswickman commented 6 months ago

@ideen1 I have it now!!!

swaminator commented 6 months ago

This is now available.

vaughngit commented 6 months ago

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