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

resource/aws_acm_certificate: Automatically trim trailing period from domain_name and subject_alternative_names #6844

Merged
merged 1 commit into from
Dec 13, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Dec 13, 2018

Trailing periods (which may come from other Terraform AWS provider resource references, notably the aws_route53_zone resource name attribute in version 1.42.0+) will generate errors with the ACM API. Rather than requiring everyone to implement the same workaround, we can automatically trim the trailing period in the resource.

Fixes #6533
Fixes #6535

Previous output from acceptance testing:

--- FAIL: TestAccAWSAcmCertificate_root_TrailingPeriod (2.74s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_acm_certificate.cert: 1 error occurred:
        	* aws_acm_certificate.cert: Error requesting certificate: ValidationException: 1 validation error detected: Value 'OMITTED.' at 'domainName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^(\*\.)?(((?!-)[A-Za-z0-9-]{0,62}[A-Za-z0-9])\.)+((?!-)[A-Za-z0-9-]{1,62}[A-Za-z0-9])$
        	status code: 400, request id: 6715d56a-fee5-11e8-9bd0-4dcda69c2aed

--- FAIL: TestAccAWSAcmCertificate_san_TrailingPeriod (2.74s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_acm_certificate.cert: 1 error occurred:
        	* aws_acm_certificate.cert: Error requesting certificate: ValidationException: 1 validation error detected: Value '[tf-acc-7681782492806076456-san.OMITTED.]' at 'subjectAlternativeNames' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 253, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: ^(\*\.)?(((?!-)[A-Za-z0-9-]{0,62}[A-Za-z0-9])\.)+((?!-)[A-Za-z0-9-]{1,62}[A-Za-z0-9])$]
        	status code: 400, request id: 6715fc72-fee5-11e8-8015-e9da8b2fcdff

Output from acceptance testing:

--- PASS: TestAccAWSAcmCertificate_dnsValidation (11.10s)
--- PASS: TestAccAWSAcmCertificate_emailValidation (12.18s)
--- PASS: TestAccAWSAcmCertificate_root (10.92s)
--- PASS: TestAccAWSAcmCertificate_root_TrailingPeriod (13.64s)
--- PASS: TestAccAWSAcmCertificate_rootAndWildcardSan (10.15s)
--- PASS: TestAccAWSAcmCertificate_san_multiple (17.00s)
--- PASS: TestAccAWSAcmCertificate_san_single (16.21s)
--- PASS: TestAccAWSAcmCertificate_san_TrailingPeriod (15.51s)
--- PASS: TestAccAWSAcmCertificate_tags (24.08s)
--- PASS: TestAccAWSAcmCertificate_wildcard (10.24s)
--- PASS: TestAccAWSAcmCertificate_wildcardAndRootSan (15.84s)

… domain_name and subject_alternative_names

Trailing periods (which may come from other Terraform AWS provider resource references, notably the aws_route53_zone name attribute in version 1.42.0+) will generate errors with the ACM API. Rather than requiring everyone to implement the same workaround, we can automatically trim the trailing period in the resource.

Previous output from acceptance testing:

```
--- FAIL: TestAccAWSAcmCertificate_root_TrailingPeriod (2.74s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_acm_certificate.cert: 1 error occurred:
        	* aws_acm_certificate.cert: Error requesting certificate: ValidationException: 1 validation error detected: Value 'OMITTED.' at 'domainName' failed to satisfy constraint: Member must satisfy regular expression pattern: ^(\*\.)?(((?!-)[A-Za-z0-9-]{0,62}[A-Za-z0-9])\.)+((?!-)[A-Za-z0-9-]{1,62}[A-Za-z0-9])$
        	status code: 400, request id: 6715d56a-fee5-11e8-9bd0-4dcda69c2aed

--- FAIL: TestAccAWSAcmCertificate_san_TrailingPeriod (2.74s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_acm_certificate.cert: 1 error occurred:
        	* aws_acm_certificate.cert: Error requesting certificate: ValidationException: 1 validation error detected: Value '[tf-acc-7681782492806076456-san.OMITTED.]' at 'subjectAlternativeNames' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 253, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: ^(\*\.)?(((?!-)[A-Za-z0-9-]{0,62}[A-Za-z0-9])\.)+((?!-)[A-Za-z0-9-]{1,62}[A-Za-z0-9])$]
        	status code: 400, request id: 6715fc72-fee5-11e8-8015-e9da8b2fcdff
```

Output from acceptance testing:

```
--- PASS: TestAccAWSAcmCertificate_dnsValidation (11.10s)
--- PASS: TestAccAWSAcmCertificate_emailValidation (12.18s)
--- PASS: TestAccAWSAcmCertificate_root (10.92s)
--- PASS: TestAccAWSAcmCertificate_root_TrailingPeriod (13.64s)
--- PASS: TestAccAWSAcmCertificate_rootAndWildcardSan (10.15s)
--- PASS: TestAccAWSAcmCertificate_san_multiple (17.00s)
--- PASS: TestAccAWSAcmCertificate_san_single (16.21s)
--- PASS: TestAccAWSAcmCertificate_san_TrailingPeriod (15.51s)
--- PASS: TestAccAWSAcmCertificate_tags (24.08s)
--- PASS: TestAccAWSAcmCertificate_wildcard (10.24s)
--- PASS: TestAccAWSAcmCertificate_wildcardAndRootSan (15.84s)
```
@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 Dec 13, 2018
@bflad bflad added this to the v1.52.0 milestone Dec 13, 2018
@bflad bflad requested a review from a team December 13, 2018 15:00
@ghost ghost added size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Dec 13, 2018
Copy link
Contributor

@tracypholmes tracypholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bflad bflad merged commit 2885168 into master Dec 13, 2018
@bflad bflad deleted the b-aws_acm_certificate-trim-period branch December 13, 2018 18:43
bflad added a commit that referenced this pull request Dec 13, 2018
@bflad
Copy link
Contributor Author

bflad commented Dec 13, 2018

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

@ghost
Copy link

ghost commented Apr 1, 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 Apr 1, 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. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
3 participants