Resource: aws_apigatewayv2_domain_name

Manages an Amazon API Gateway Version 2 domain name. More information can be found in the Amazon API Gateway Developer Guide.

Example Usage

Basic

resource "aws_apigatewayv2_domain_name" "example" {
  domain_name = "ws-api.example.com"

  domain_name_configuration {
    certificate_arn = aws_acm_certificate.example.arn
    endpoint_type   = "REGIONAL"
    security_policy = "TLS_1_2"
  }
}

Associated Route 53 Resource Record

resource "aws_apigatewayv2_domain_name" "example" {
  domain_name = "http-api.example.com"

  domain_name_configuration {
    certificate_arn = aws_acm_certificate.example.arn
    endpoint_type   = "REGIONAL"
    security_policy = "TLS_1_2"
  }
}

resource "aws_route53_record" "example" {
  name    = aws_apigatewayv2_domain_name.example.domain_name
  type    = "A"
  zone_id = aws_route53_zone.example.zone_id

  alias {
    name                   = aws_apigatewayv2_domain_name.example.domain_name_configuration[0].target_domain_name
    zone_id                = aws_apigatewayv2_domain_name.example.domain_name_configuration[0].hosted_zone_id
    evaluate_target_health = false
  }
}

Argument Reference

This resource supports the following arguments:

domain_name_configuration

mutual_tls_authentication

Attribute Reference

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

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import aws_apigatewayv2_domain_name using the domain name. For example:

import {
  to = aws_apigatewayv2_domain_name.example
  id = "ws-api.example.com"
}

Using terraform import, import aws_apigatewayv2_domain_name using the domain name. For example:

% terraform import aws_apigatewayv2_domain_name.example ws-api.example.com