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

Expose status attribute for aws_acm_certificate resource for automated removal of cert verification DNS record #3855

Closed
samjgalbraith opened this issue Mar 21, 2018 · 4 comments · Fixed by #13513
Assignees
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/acm Issues and PRs that pertain to the acm service.
Milestone

Comments

@samjgalbraith
Copy link

samjgalbraith commented Mar 21, 2018

What I want to be able to do is illustrated by the below config: I want to have the DNS record which is used to demonstrate domain ownership have a count of 0 once the certificate is issued, so that the record will go away automatically and not clutter my DNS records. However, status does not seem to be exposed on the aws_acm_certificate resource. If I try to use the aws_acm_certificate data source, I can not seem to get this information either. If I apply a filter on the data source, then the apply operation fails whenever the filter condition returns an empty result, so I can't use this either. The cleanest solution seems to be exposing status on the certificate resource. This should be easy enough to add, as I see it's part of the describe-certificate response in the AWS cli and API:
https://docs.aws.amazon.com/cli/latest/reference/acm/describe-certificate.html

Terraform Version

Terraform v0.11.3

  • provider.aws v1.11.0

Affected Resource(s)

  • aws_acm_certificate

Terraform Configuration Files

data "aws_route53_zone" "services" {
  name = "${local.domain_name}"
}

resource "aws_acm_certificate" "service_internet_facing" {
  domain_name = "${aws_route53_record.service.name}"
  validation_method = "DNS"
}

# Certificate domain ownership validation by DNS involves putting a DNS record in to prove that you have access to DNS management.
resource "aws_route53_record" "service_cert_validation_by_dns" {
  count = "${aws_acm_certificate.status == "ISSUED" ? 0 : 1}"
  name = "${aws_acm_certificate.service_internet_facing.domain_validation_options.0.resource_record_name}"
  type = "${aws_acm_certificate.service_internet_facing.domain_validation_options.0.resource_record_type}"
  zone_id = "${data.aws_route53_zone.services.zone_id}"
  records = ["${aws_acm_certificate.service_internet_facing.domain_validation_options.0.resource_record_value}"]
  ttl = 60
}

resource "aws_acm_certificate_validation" "service_internet_facing" {
  certificate_arn = "${aws_acm_certificate.service_internet_facing.arn}"
  validation_record_fqdns = ["${aws_route53_record.service_cert_validation_by_dns.fqdn}"]
}
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/acm Issues and PRs that pertain to the acm service. labels Mar 21, 2018
@stszap
Copy link
Contributor

stszap commented Sep 5, 2018

But what about renewal? If I understand correctly it wouldn't work if you delete validation dns record.

@bflad bflad self-assigned this May 27, 2020
bflad added a commit that referenced this issue May 27, 2020
Reference: #3855
Reference: #6082
Reference: #8755
Reference: #12075
Reference: #13053

Notable changes:

```
ENHANCEMENTS:

* resource/aws_acm_certificate: Add `status` attribute

BUG FIXES:

* resource/aws_acm_certificate: Detect `AMAZON_ISSUED` type `validation_method` value directly from API response instead of custom logic
* resource/aws_acm_certificate: Increase deletion retries from 10 minutes to 20 minutes (better support API Gateway Custom Domain deletion)
```

Other changes:

- Documents `subject_alternative_names` argument removal procedures
- Improves potentially confusing error message during asynchronous ACM validation assignment

Output from acceptance testing:

```
--- PASS: TestAccAWSAcmCertificate_imported_IpAddress (36.64s)
--- PASS: TestAccAWSAcmCertificate_root_TrailingPeriod (37.74s)
--- PASS: TestAccAWSAcmCertificate_wildcard (38.86s)
--- PASS: TestAccAWSAcmCertificate_wildcardAndRootSan (39.08s)
--- PASS: TestAccAWSAcmCertificate_emailValidation (39.11s)
--- PASS: TestAccAWSAcmCertificate_dnsValidation (39.35s)
--- PASS: TestAccAWSAcmCertificate_rootAndWildcardSan (39.62s)
--- PASS: TestAccAWSAcmCertificate_disableCTLogging (41.62s)
--- PASS: TestAccAWSAcmCertificate_san_single (41.93s)
--- PASS: TestAccAWSAcmCertificate_san_TrailingPeriod (42.00s)
--- PASS: TestAccAWSAcmCertificate_san_multiple (42.05s)
--- PASS: TestAccAWSAcmCertificate_root (42.07s)
--- PASS: TestAccAWSAcmCertificate_privateCert (47.46s)
--- PASS: TestAccAWSAcmCertificate_imported_DomainName (54.51s)
--- PASS: TestAccAWSAcmCertificate_tags (85.67s)
```
@bflad bflad added this to the v2.65.0 milestone Jun 4, 2020
@bflad
Copy link
Contributor

bflad commented Jun 4, 2020

Support for the status attribute has been merged and will release with version 2.65.0 of the Terraform AWS Provider, likely later today. 👍

@ghost
Copy link

ghost commented Jun 5, 2020

This has been released in version 2.65.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 Jul 5, 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 Jul 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/acm Issues and PRs that pertain to the acm service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants