Skip to content

Resource: awsAmplifyDomainAssociation

Provides an Amplify Domain Association resource.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsAmplifyAppExample = new aws.amplifyApp.AmplifyApp(this, "example", {
  customRule: [
    {
      source: "https://example.com",
      status: "302",
      target: "https://www.example.com",
    },
  ],
  name: "app",
});
const awsAmplifyBranchMaster = new aws.amplifyBranch.AmplifyBranch(
  this,
  "master",
  {
    appId: awsAmplifyAppExample.id,
    branchName: "master",
  }
);
const awsAmplifyDomainAssociationExample =
  new aws.amplifyDomainAssociation.AmplifyDomainAssociation(this, "example_2", {
    appId: awsAmplifyAppExample.id,
    domainName: "example.com",
    subDomain: [
      {
        branchName: awsAmplifyBranchMaster.branchName,
        prefix: "",
      },
      {
        branchName: awsAmplifyBranchMaster.branchName,
        prefix: "www",
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsAmplifyDomainAssociationExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • appId - (Required) Unique ID for an Amplify app.
  • domainName - (Required) Domain name for the domain association.
  • enableAutoSubDomain - (Optional) Enables the automated creation of subdomains for branches.
  • subDomain - (Required) Setting for the subdomain. Documented below.
  • waitForVerification - (Optional) If enabled, the resource will wait for the domain association status to change to PENDING_DEPLOYMENT or available. Setting this to false will skip the process. Default: true.

The subDomain configuration block supports the following arguments:

  • branchName - (Required) Branch name setting for the subdomain.
  • prefix - (Required) Prefix setting for the subdomain.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • arn - ARN for the domain association.
  • certificateVerificationDnsRecord - The DNS record for certificate verification.

The subDomain configuration block exports the following attributes:

  • dnsRecord - DNS record for the subdomain.
  • verified - Verified status of the subdomain.

Import

Amplify domain association can be imported using appId and domainName, e.g.,

$ terraform import aws_amplify_domain_association.app d2ypk4k47z8u6/example.com