createDomainAssociation method

Future<CreateDomainAssociationResult> createDomainAssociation({
  1. required String appId,
  2. required String domainName,
  3. required List<SubDomainSetting> subDomainSettings,
  4. List<String>? autoSubDomainCreationPatterns,
  5. String? autoSubDomainIAMRole,
  6. bool? enableAutoSubDomain,
})

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

May throw BadRequestException. May throw UnauthorizedException. May throw NotFoundException. May throw InternalFailureException. May throw LimitExceededException. May throw DependentServiceFailureException.

Parameter appId : The unique ID for an Amplify app.

Parameter domainName : The domain name for the domain association.

Parameter subDomainSettings : The setting for the subdomain.

Parameter autoSubDomainCreationPatterns : Sets the branch patterns for automatic subdomain creation.

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

Parameter enableAutoSubDomain : Enables the automated creation of subdomains for branches.

Implementation

Future<CreateDomainAssociationResult> createDomainAssociation({
  required String appId,
  required String domainName,
  required List<SubDomainSetting> subDomainSettings,
  List<String>? autoSubDomainCreationPatterns,
  String? autoSubDomainIAMRole,
  bool? enableAutoSubDomain,
}) async {
  ArgumentError.checkNotNull(appId, 'appId');
  _s.validateStringLength(
    'appId',
    appId,
    1,
    20,
    isRequired: true,
  );
  ArgumentError.checkNotNull(domainName, 'domainName');
  _s.validateStringLength(
    'domainName',
    domainName,
    0,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(subDomainSettings, 'subDomainSettings');
  _s.validateStringLength(
    'autoSubDomainIAMRole',
    autoSubDomainIAMRole,
    0,
    1000,
  );
  final $payload = <String, dynamic>{
    'domainName': domainName,
    'subDomainSettings': subDomainSettings,
    if (autoSubDomainCreationPatterns != null)
      'autoSubDomainCreationPatterns': autoSubDomainCreationPatterns,
    if (autoSubDomainIAMRole != null)
      'autoSubDomainIAMRole': autoSubDomainIAMRole,
    if (enableAutoSubDomain != null)
      'enableAutoSubDomain': enableAutoSubDomain,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/apps/${Uri.encodeComponent(appId)}/domains',
    exceptionFnMap: _exceptionFns,
  );
  return CreateDomainAssociationResult.fromJson(response);
}