

This is the new *Amazon CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [Amazon CloudFormation User Guide](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/Welcome.html).

# AWS::AmplifyGen3::DomainAssociation

The `AWS::AmplifyGen3::DomainAssociation` resource specifies a custom domain for an Amazon Amplify Gen 3 app, and how the domain routes traffic.

## Syntax
<a name="aws-resource-amplifygen3-domainassociation-syntax"></a>

To declare this entity in your Amazon CloudFormation template, use the following syntax:

### JSON
<a name="aws-resource-amplifygen3-domainassociation-syntax.json"></a>

```json
{
  "Type" : "AWS::AmplifyGen3::DomainAssociation",
  "Properties" : {
      "[AppName](#cfn-amplifygen3-domainassociation-appname)" : {{String}},
      "[DnsManagementType](#cfn-amplifygen3-domainassociation-dnsmanagementtype)" : {{String}},
      "[DomainName](#cfn-amplifygen3-domainassociation-domainname)" : {{String}},
      "[Routing](#cfn-amplifygen3-domainassociation-routing)" : {{Routing}},
      "[Tags](#cfn-amplifygen3-domainassociation-tags)" : {{[ Tag, ... ]}}
    }
}
```

### YAML
<a name="aws-resource-amplifygen3-domainassociation-syntax.yaml"></a>

```yaml
Type: AWS::AmplifyGen3::DomainAssociation
Properties:
  [AppName](#cfn-amplifygen3-domainassociation-appname): {{String}}
  [DnsManagementType](#cfn-amplifygen3-domainassociation-dnsmanagementtype): {{String}}
  [DomainName](#cfn-amplifygen3-domainassociation-domainname): {{String}}
  [Routing](#cfn-amplifygen3-domainassociation-routing): {{
    Routing}}
  [Tags](#cfn-amplifygen3-domainassociation-tags): {{
    - Tag}}
```

## Properties
<a name="aws-resource-amplifygen3-domainassociation-properties"></a>

`AppName`  <a name="cfn-amplifygen3-domainassociation-appname"></a>
The name of the app.  
*Required*: Yes  
*Type*: String  
*Minimum*: `1`  
*Maximum*: `40`  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`DnsManagementType`  <a name="cfn-amplifygen3-domainassociation-dnsmanagementtype"></a>
Specifies who manages the DNS records for the domain. Valid values:  
+ `ROUTE_53`: Amazon Amplify Gen 3 creates the records in an Amazon Route 53 hosted zone in your account.
+ `MANUAL`: You create the records with your DNS provider.
+ `NS_DELEGATION`: Amazon Amplify Gen 3 creates a hosted zone, and you delegate the domain to its name servers.
*Required*: Yes  
*Type*: String  
*Allowed values*: `ROUTE_53 | MANUAL | NS_DELEGATION`  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`DomainName`  <a name="cfn-amplifygen3-domainassociation-domainname"></a>
The fully qualified domain name.  
*Required*: Yes  
*Type*: String  
*Pattern*: `^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.){1,31}[a-z]{2,}$`  
*Minimum*: `4`  
*Maximum*: `64`  
*Update requires*: [Replacement](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Routing`  <a name="cfn-amplifygen3-domainassociation-routing"></a>
The routing configuration for the domain.  
*Required*: Yes  
*Type*: [Routing](aws-properties-amplifygen3-domainassociation-routing.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Tags`  <a name="cfn-amplifygen3-domainassociation-tags"></a>
An array of key-value pairs to apply to this resource.  
For more information, see [Tag](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/aws-properties-resource-tags.html).  
*Required*: No  
*Type*: Array of [Tag](aws-properties-amplifygen3-domainassociation-tag.md)  
*Update requires*: [No interruption](https://docs.amazonaws.cn/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return values
<a name="aws-resource-amplifygen3-domainassociation-return-values"></a>

### Ref
<a name="aws-resource-amplifygen3-domainassociation-return-values-ref"></a>

When you pass the logical ID of this resource to the intrinsic `Ref` function, `Ref` returns the ARN of the domain association.

For more information about using the `Ref` function, see [`Ref`](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html).

### Fn::GetAtt
<a name="aws-resource-amplifygen3-domainassociation-return-values-fn--getatt"></a>

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [`Fn::GetAtt`](https://docs.amazonaws.cn/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html).

#### 
<a name="aws-resource-amplifygen3-domainassociation-return-values-fn--getatt-fn--getatt"></a>

`CreatedAt`  <a name="CreatedAt-fn::getatt"></a>
The time at which the domain association was created. The value is in ISO-8601 format.

`DomainAssociationArn`  <a name="DomainAssociationArn-fn::getatt"></a>
The Amazon Resource Name (ARN) of the domain association.

## Remarks
<a name="aws-resource-amplifygen3-domainassociation--remarks"></a>

Amazon CloudFormation reports `CREATE_COMPLETE` for this resource as soon as Amazon Amplify Gen 3 accepts the domain association. It doesn't wait for the domain to become `ACTIVE`.

With `DnsManagementType` set to `MANUAL` or `NS_DELEGATION`, the domain stays in a `PENDING_` status, such as `PENDING_DNS_VALIDATION` or `PENDING_NS_DELEGATION`, until you finish the DNS setup with your DNS provider. Until then, the domain doesn't serve traffic, even though the stack operation succeeded.

## Examples
<a name="aws-resource-amplifygen3-domainassociation--examples"></a>

### Create a custom domain that redirects
<a name="aws-resource-amplifygen3-domainassociation--examples--Create_a_custom_domain_that_redirects"></a>

The following example associates the domain `www.example.com` with an app and redirects its traffic to another URL. The DNS records are managed manually.

#### JSON
<a name="aws-resource-amplifygen3-domainassociation--examples--Create_a_custom_domain_that_redirects--json"></a>

```json
{
    "Resources": {
        "MyDomain": {
            "Type": "AWS::AmplifyGen3::DomainAssociation",
            "Properties": {
                "AppName": "my-app",
                "DomainName": "www.example.com",
                "DnsManagementType": "MANUAL",
                "Routing": {
                    "Redirect": {
                        "TargetUrl": "https://example.com/welcome",
                        "StatusCode": "HTTP_302"
                    }
                }
            }
        }
    }
}
```

#### YAML
<a name="aws-resource-amplifygen3-domainassociation--examples--Create_a_custom_domain_that_redirects--yaml"></a>

```yaml
Resources:
  MyDomain:
    Type: AWS::AmplifyGen3::DomainAssociation
    Properties:
      AppName: my-app
      DomainName: www.example.com
      DnsManagementType: MANUAL
      Routing:
        Redirect:
          TargetUrl: https://example.com/welcome
          StatusCode: HTTP_302
```