CreateDomainAssociationCommand

Creates a new domain association for an Amplify app. This action associates a custom domain with the Amplify app

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { AmplifyClient, CreateDomainAssociationCommand } from "@aws-sdk/client-amplify"; // ES Modules import
// const { AmplifyClient, CreateDomainAssociationCommand } = require("@aws-sdk/client-amplify"); // CommonJS import
const client = new AmplifyClient(config);
const input = { // CreateDomainAssociationRequest
  appId: "STRING_VALUE", // required
  domainName: "STRING_VALUE", // required
  enableAutoSubDomain: true || false,
  subDomainSettings: [ // SubDomainSettings // required
    { // SubDomainSetting
      prefix: "STRING_VALUE", // required
      branchName: "STRING_VALUE", // required
    },
  ],
  autoSubDomainCreationPatterns: [ // AutoSubDomainCreationPatterns
    "STRING_VALUE",
  ],
  autoSubDomainIAMRole: "STRING_VALUE",
  certificateSettings: { // CertificateSettings
    type: "AMPLIFY_MANAGED" || "CUSTOM", // required
    customCertificateArn: "STRING_VALUE",
  },
};
const command = new CreateDomainAssociationCommand(input);
const response = await client.send(command);
// { // CreateDomainAssociationResult
//   domainAssociation: { // DomainAssociation
//     domainAssociationArn: "STRING_VALUE", // required
//     domainName: "STRING_VALUE", // required
//     enableAutoSubDomain: true || false, // required
//     autoSubDomainCreationPatterns: [ // AutoSubDomainCreationPatterns
//       "STRING_VALUE",
//     ],
//     autoSubDomainIAMRole: "STRING_VALUE",
//     domainStatus: "PENDING_VERIFICATION" || "IN_PROGRESS" || "AVAILABLE" || "IMPORTING_CUSTOM_CERTIFICATE" || "PENDING_DEPLOYMENT" || "AWAITING_APP_CNAME" || "FAILED" || "CREATING" || "REQUESTING_CERTIFICATE" || "UPDATING", // required
//     updateStatus: "REQUESTING_CERTIFICATE" || "PENDING_VERIFICATION" || "IMPORTING_CUSTOM_CERTIFICATE" || "PENDING_DEPLOYMENT" || "AWAITING_APP_CNAME" || "UPDATE_COMPLETE" || "UPDATE_FAILED",
//     statusReason: "STRING_VALUE", // required
//     certificateVerificationDNSRecord: "STRING_VALUE",
//     subDomains: [ // SubDomains // required
//       { // SubDomain
//         subDomainSetting: { // SubDomainSetting
//           prefix: "STRING_VALUE", // required
//           branchName: "STRING_VALUE", // required
//         },
//         verified: true || false, // required
//         dnsRecord: "STRING_VALUE", // required
//       },
//     ],
//     certificate: { // Certificate
//       type: "AMPLIFY_MANAGED" || "CUSTOM", // required
//       customCertificateArn: "STRING_VALUE",
//       certificateVerificationDNSRecord: "STRING_VALUE",
//     },
//   },
// };

CreateDomainAssociationCommand Input

Parameter
Type
Description
appId
Required
string | undefined

The unique ID for an Amplify app.

domainName
Required
string | undefined

The domain name for the domain association.

subDomainSettings
Required
SubDomainSetting[] | undefined

The setting for the subdomain.

autoSubDomainCreationPatterns
string[] | undefined

Sets the branch patterns for automatic subdomain creation.

autoSubDomainIAMRole
string | undefined

The required AWS Identity and Access Management (IAM) service role for the Amazon Resource Name (ARN) for automatically creating subdomains.

certificateSettings
CertificateSettings | undefined

The type of SSL/TLS certificate to use for your custom domain. If you don't specify a certificate type, Amplify uses the default certificate that it provisions and manages for you.

enableAutoSubDomain
boolean | undefined

Enables the automated creation of subdomains for branches.

CreateDomainAssociationCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
domainAssociation
Required
DomainAssociation | undefined

Describes the structure of a domain association, which associates a custom domain with an Amplify app.

Throws

Name
Fault
Details
BadRequestException
client

A request contains unexpected data.

DependentServiceFailureException
server

An operation failed because a dependent service threw an exception.

InternalFailureException
server

The service failed to perform an operation due to an internal issue.

LimitExceededException
client

A resource could not be created because service quotas were exceeded.

NotFoundException
client

An entity was not found during an operation.

UnauthorizedException
client

An operation failed due to a lack of access.

AmplifyServiceException
Base exception class for all service exceptions from Amplify service.