terraform-aws-modules / terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/apigateway-v2/aws
Apache License 2.0
144 stars 188 forks source link

Improve complete-http example with aws_route53_record #1

Closed ofhouse closed 4 years ago

ofhouse commented 4 years ago

Because I just searched for a good hour how to create a aws_route53_record alias for the custom domain from the module I want to leave my findings here for reference:

module "api_gateway" {
  source = "terraform-aws-modules/apigateway-v2/aws"

  name          = "dev-http"
  protocol_type = "HTTP"

  domain_name = "terraform-aws-modules.modules.tf"

  ...

}

data "aws_route53_zone" "root" {
  name         = "modules.tf."
}

resource "aws_route53_record" "api" {
  zone_id = data.aws_route53_zone.root.zone_id
  name    = "terraform-aws-modules.modules.tf"
  type    = "A"

  alias {
    name                   = module.api_gateway.this_apigatewayv2_domain_name_configuration.0.target_domain_name
    zone_id                = module.api_gateway.this_apigatewayv2_domain_name_configuration.0.hosted_zone_id
    evaluate_target_health = false
  }
}

Maybe it makes sense to add this to the complete http-example because the documentation about this in the AWS provider is currently not merged (https://github.com/terraform-providers/terraform-provider-aws/pull/12920).

antonbabenko commented 4 years ago

Great addition, @ofhouse!

I have just added this to this module.

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.