Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create api_gateway_domain using aws_route53_zone.name #7501

Closed
grodzik opened this issue Feb 11, 2019 · 2 comments · Fixed by #14220
Closed

Unable to create api_gateway_domain using aws_route53_zone.name #7501

grodzik opened this issue Feb 11, 2019 · 2 comments · Fixed by #14220
Assignees
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Milestone

Comments

@grodzik
Copy link

grodzik commented Feb 11, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.11

  • provider.aws v1.58.0

Affected Resource(s)

  • aws_api_gateway_domain_name

Terraform Configuration Files

provider "aws" {
    region = "eu-west-1"
}

provider "aws" {
    region = "us-east-1"
    alias = "virginia"
}

variable "domain" {}
variable "subdomain" {}

data "aws_route53_zone" "domain" {
  name = "${var.domain}"
}

resource "aws_acm_certificate" "crt" {
  domain_name = "${var.subdomain}.${data.aws_route53_zone.domain.name}"
  validation_method = "DNS"
  provider = "aws.virginia"
  lifecycle {
    create_before_destroy = true
  }
}

resource "aws_route53_record" "crt_record" {
  zone_id = "${data.aws_route53_zone.domain.name}"
  name = "${aws_acm_certificate.crt.domain_validation_options.0.resource_record_name}"
  type = "${aws_acm_certificate.crt.domain_validation_options.0.resource_record_type}"
  ttl = 60
  records = ["${aws_acm_certificate.crt.domain_validation_options.0.resource_record_value}"]
}

resource "aws_route53_record" "record" {
  zone_id = "${data.aws_route53_zone.domain.name}"
  name = "${var.subdomain}.${data.aws_route53_zone.domain.name}"
  type = "A"

  alias {
    name = "${aws_api_gateway_domain_name.api.cloudfront_domain_name}"
    zone_id = "${aws_api_gateway_domain_name.api.cloudfront_zone_id}"
    evaluate_target_health = false
  }
}

resource "aws_acm_certificate_validation" "crt_val" {
  certificate_arn = "${aws_acm_certificate.crt.arn}"
  validation_record_fqdns = ["${aws_route53_record.crt_record.fqdn}"]
  provider = "aws.virginia"
}

resource "aws_api_gateway_domain_name" "api" {
  domain_name = "${var.subdomain}.${data.aws_route53_zone.domain.name}"
  certificate_arn = "${aws_acm_certificate.crt.arn}"
}

Debug Output

https://gist.github.com/grodzik/485b73bd45c4c4ba7af0dd5e3c210cf6

Expected Behavior

api_gateway_domain_name should be created.

Actual Behavior

Below error accures:

* aws_api_gateway_domain_name.api: Error creating API Gateway Domain Name: BadRequestException: Trailing period should be omitted from domain name
    status code: 400, request id: 56a81101-2deb-11e9-aadc-11aff297d7ee

This is related to this line from the log. There's dot at the end. Although it's taken from same source, aws_route53_record doesn't have such issue (see line 53 of the log)

Running above code for the first time will show also error about non-existant domain for the certificate, which is not meaningful for this issue.

@ghost
Copy link

ghost commented Jul 31, 2020

This has been released in version 3.0.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Aug 30, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Aug 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
3 participants