Resource: aws_amplify_domain_association

Provides an Amplify Domain Association resource.

Example Usage

resource "aws_amplify_app" "example" {
  name = "app"

  # Setup redirect from https://example.com to https://www.example.com
  custom_rule {
    source = "https://example.com"
    status = "302"
    target = "https://www.example.com"
  }
}

resource "aws_amplify_branch" "master" {
  app_id      = aws_amplify_app.example.id
  branch_name = "master"
}

resource "aws_amplify_domain_association" "example" {
  app_id      = aws_amplify_app.example.id
  domain_name = "example.com"

  # https://example.com
  sub_domain {
    branch_name = aws_amplify_branch.master.branch_name
    prefix      = ""
  }

  # https://www.example.com
  sub_domain {
    branch_name = aws_amplify_branch.master.branch_name
    prefix      = "www"
  }
}

Argument Reference

This resource supports the following arguments:

The sub_domain configuration block supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

The sub_domain configuration block exports the following attributes:

Import

In Terraform v1.5.0 and later, use an import block to import Amplify domain association using app_id and domain_name. For example:

import {
  to = aws_amplify_domain_association.app
  id = "d2ypk4k47z8u6/example.com"
}

Using terraform import, import Amplify domain association using app_id and domain_name. For example:

% terraform import aws_amplify_domain_association.app d2ypk4k47z8u6/example.com