3
votes

While executing terraform plan I got no errors, but when I execute terraform apply I am receiving below error.

Terraform plan output:-

+ aws_route53_record.alm_route_record1
      id:                                        <computed>
      allow_overwrite:                           <computed>
      fqdn:                                      <computed>
      name:                                      "${aws_acm_certificate.acm.domain_validation_options.0.resource_record_name}"
      records.#:                                 <computed>
      ttl:                                       "300"
      type:                                      "${aws_acm_certificate.acm.domain_validation_options.0.resource_record_type}"
      zone_id:                                   "Z2J2U5QM63SJ94"

acm.tf

resource "aws_acm_certificate" "acm" {
  domain_name       = “example.com”
  validation_method = "DNS"

  tags = {
    Environment   = "${lookup(var.environment, terraform.workspace)}"
    ManagedBy     = "terraform"
  }
}

data "aws_route53_zone" "route_zone" {
  name         = "example.org."
  private_zone = false
}

resource "aws_route53_record" "alm_route_record1" {
  name    = "${aws_acm_certificate.acm.domain_validation_options.0.resource_record_name}"
  type    = "${aws_acm_certificate.acm.domain_validation_options.0.resource_record_type}"
  zone_id = "${data.aws_route53_zone.route_zone.id}"
  records = ["${aws_acm_certificate.acm.domain_validation_options.0.resource_record_value}"]
  ttl     = 300
}

resource "aws_acm_certificate_validation" "dns_validation" {
  certificate_arn         = "${aws_acm_certificate.acm.arn}"
  validation_record_fqdns = ["${aws_route53_record.alm_route_record1.fqdn}"]
}

Error logs:-

aws_route53_record.alm_route_record1: [ERR]: Error building changeset: InvalidChangeBatch: [Tried to create resource record set [name='_c12c2dee87ee95f2104e7a94875e5519.ca.tuigroup.com.', type='CNAME'] but it already exists] status code: 400, request id: 4f145fdb-45a0-11e9-b0f7-4baff3471f37

After hitting the WebURL of my page it's showing

503 Service Temporarily Unavailable

I feel records are accepting existing CNAME

1

1 Answers

0
votes

Seems the latest aws providers after 2.0 has bugs (https://github.com/terraform-providers/terraform-provider-aws/issues/7918)

Please stay with older version, such as version 1.60 and waiting for the fix.

provider "aws" {
  access_key = "${var.access_key}"
  secret_key = "${var.secret_key}"
  region     = "${var.region}"

  version = "~> 1.60"
}