Resource: aws_cognito_user_pool_domain

Provides a Cognito User Pool Domain resource.

Example Usage

Amazon Cognito domain

resource "aws_cognito_user_pool_domain" "main" {
  domain       = "example-domain"
  user_pool_id = aws_cognito_user_pool.example.id
}

resource "aws_cognito_user_pool" "example" {
  name = "example-pool"
}

Custom Cognito domain

resource "aws_cognito_user_pool_domain" "main" {
  domain          = "example-domain"
  certificate_arn = aws_acm_certificate.cert.arn
  user_pool_id    = aws_cognito_user_pool.example.id
}

resource "aws_cognito_user_pool" "example" {
  name = "example-pool"
}

data "aws_route53_zone" "example" {
  name = "example.com"
}

resource "aws_route53_record" "auth-cognito-A" {
  name    = aws_cognito_user_pool_domain.main.domain
  type    = "A"
  zone_id = data.aws_route53_zone.example.zone_id
  alias {
    evaluate_target_health = false

    name    = aws_cognito_user_pool_domain.main.cloudfront_distribution
    zone_id = aws_cognito_user_pool_domain.main.cloudfront_distribution_zone_id
  }
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

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

Import

In Terraform v1.5.0 and later, use an import block to import Cognito User Pool Domains using the domain. For example:

import {
  to = aws_cognito_user_pool_domain.main
  id = "auth.example.org"
}

Using terraform import, import Cognito User Pool Domains using the domain. For example:

% terraform import aws_cognito_user_pool_domain.main auth.example.org