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

tests/resource/aws_api_gateway_domain_name: Remove hardcoded environment variable handling, create public ACM certificate, improve state value checks #16139

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Nov 11, 2020

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Reference: #8316
Closes #14664
Reference: #15737

Release note for CHANGELOG:

NONE

Output from acceptance testing in AWS Commercial:

--- PASS: TestAccAWSAPIGatewayDomainName_disappears (20.54s)
--- PASS: TestAccAWSAPIGatewayDomainName_RegionalCertificateArn (81.84s)
--- PASS: TestAccAWSAPIGatewayDomainName_SecurityPolicy (139.42s)
--- PASS: TestAccAWSAPIGatewayDomainName_Tags (203.73s)
--- SKIP: TestAccAWSAPIGatewayDomainName_CertificateName (0.00s)
--- SKIP: TestAccAWSAPIGatewayDomainName_RegionalCertificateName (0.00s)

Output from acceptance testing in AWS GovCloud (US) (other tests failing with ACM quota limits):

--- SKIP: TestAccAWSAPIGatewayDomainName_CertificateArn (1.58s)

…ent variable handling, create public ACM certificate, improve state value checks

Reference: #8316
Reference: #14664
Reference: #15737

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSAPIGatewayDomainName_disappears (20.54s)
--- PASS: TestAccAWSAPIGatewayDomainName_RegionalCertificateArn (81.84s)
--- PASS: TestAccAWSAPIGatewayDomainName_SecurityPolicy (139.42s)
--- PASS: TestAccAWSAPIGatewayDomainName_Tags (203.73s)
--- SKIP: TestAccAWSAPIGatewayDomainName_CertificateName (0.00s)
--- SKIP: TestAccAWSAPIGatewayDomainName_RegionalCertificateName (0.00s)
```

Output from acceptance testing in AWS GovCloud (US) (other tests failing with ACM quota limits):

```
--- SKIP: TestAccAWSAPIGatewayDomainName_CertificateArn (1.58s)
```
@bflad bflad added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/apigateway Issues and PRs that pertain to the apigateway service. technical-debt Addresses areas of the codebase that need refactoring or redesign. labels Nov 11, 2020
@bflad bflad requested a review from a team as a code owner November 11, 2020 12:30
@ghost ghost added size/L Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. labels Nov 11, 2020
@bflad bflad changed the title tests/resource/aws_api_gateway_domain_name: Remove hardcoded environm…ent variable handling, create public ACM certificate, improve state value checks tests/resource/aws_api_gateway_domain_name: Remove hardcoded environment variable handling, create public ACM certificate, improve state value checks Nov 11, 2020
@bflad bflad added the partition/aws-us-gov Pertains to the aws-us-gov partition. label Nov 11, 2020
ewbankkit added a commit to ewbankkit/terraform-provider-aws that referenced this pull request Nov 11, 2020
…ting mutual TLS (relates: hashicorp#16139).

Acceptance test output:

$ ACM_CERTIFICATE_ROOT_DOMAIN=<domain name> make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayV2DomainName_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2DomainName_ -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2DomainName_basic
=== PAUSE TestAccAWSAPIGatewayV2DomainName_basic
=== RUN   TestAccAWSAPIGatewayV2DomainName_disappears
=== PAUSE TestAccAWSAPIGatewayV2DomainName_disappears
=== RUN   TestAccAWSAPIGatewayV2DomainName_Tags
=== PAUSE TestAccAWSAPIGatewayV2DomainName_Tags
=== RUN   TestAccAWSAPIGatewayV2DomainName_UpdateCertificate
=== PAUSE TestAccAWSAPIGatewayV2DomainName_UpdateCertificate
=== RUN   TestAccAWSAPIGatewayV2DomainName_MutualTlsAuthentication
=== PAUSE TestAccAWSAPIGatewayV2DomainName_MutualTlsAuthentication
=== CONT  TestAccAWSAPIGatewayV2DomainName_basic
=== CONT  TestAccAWSAPIGatewayV2DomainName_UpdateCertificate
=== CONT  TestAccAWSAPIGatewayV2DomainName_MutualTlsAuthentication
=== CONT  TestAccAWSAPIGatewayV2DomainName_Tags
=== CONT  TestAccAWSAPIGatewayV2DomainName_disappears
--- PASS: TestAccAWSAPIGatewayV2DomainName_disappears (22.46s)
--- PASS: TestAccAWSAPIGatewayV2DomainName_Tags (83.52s)
--- PASS: TestAccAWSAPIGatewayV2DomainName_MutualTlsAuthentication (207.72s)
--- PASS: TestAccAWSAPIGatewayV2DomainName_basic (240.48s)
--- PASS: TestAccAWSAPIGatewayV2DomainName_UpdateCertificate (758.06s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	758.484s
Comment on lines +348 to +391
data "aws_route53_zone" "test" {
name = %[1]q
private_zone = false
}

resource "aws_acm_certificate" "test" {
domain_name = %[2]q
validation_method = "DNS"
}

#
# for_each acceptance testing requires:
# https://github.com/hashicorp/terraform-plugin-sdk/issues/536
#
# resource "aws_route53_record" "test" {
# for_each = {
# for dvo in aws_acm_certificate.test.domain_validation_options: dvo.domain_name => {
# name = dvo.resource_record_name
# record = dvo.resource_record_value
# type = dvo.resource_record_type
# }
# }

# allow_overwrite = true
# name = each.value.name
# records = [each.value.record]
# ttl = 60
# type = each.value.type
# zone_id = data.aws_route53_zone.test.zone_id
# }

resource "aws_route53_record" "test" {
allow_overwrite = true
name = tolist(aws_acm_certificate.test.domain_validation_options)[0].resource_record_name
records = [tolist(aws_acm_certificate.test.domain_validation_options)[0].resource_record_value]
ttl = 60
type = tolist(aws_acm_certificate.test.domain_validation_options)[0].resource_record_type
zone_id = data.aws_route53_zone.test.zone_id
}

resource "aws_acm_certificate_validation" "test" {
certificate_arn = aws_acm_certificate.test.arn
validation_record_fqdns = [aws_route53_record.test.fqdn]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, in #15258 I have pulled this into a separate function as I will use it in a couple of places: 4a7197b#diff-de07b61dfd6679fbda71d2c219efc2356d9a0757a6366304a5361ee09f86803bR395-R441.
If this PR is merged first I'll refactor testAccAWSAPIGatewayDomainNameConfig_CertificateArn to use this new function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay cool -- feel free to add it to the contributing guide and create a followup technical debt issue. 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Done: #16171.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM.

$ ACM_CERTIFICATE_ROOT_DOMAIN=<domain name> make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayDomainName_CertificateArn'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayDomainName_CertificateArn -timeout 120m
=== RUN   TestAccAWSAPIGatewayDomainName_CertificateArn
=== PAUSE TestAccAWSAPIGatewayDomainName_CertificateArn
=== CONT  TestAccAWSAPIGatewayDomainName_CertificateArn
--- PASS: TestAccAWSAPIGatewayDomainName_CertificateArn (963.01s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	963.079s

@bflad bflad added this to the v3.15.0 milestone Nov 12, 2020
@bflad bflad merged commit 94161a5 into master Nov 12, 2020
@bflad bflad deleted the t-aws_api_gateway_domain_name-hardcoded-region branch November 12, 2020 15:29
@ghost
Copy link

ghost commented Nov 12, 2020

This has been released in version 3.15.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!

ewbankkit added a commit to ewbankkit/terraform-provider-aws that referenced this pull request Nov 13, 2020
…ing mutual TLS (relates: hashicorp#16139).

Acceptance test output:

$ ACM_CERTIFICATE_ROOT_DOMAIN=<domain name> make testacc TEST=./aws TESTARGS='-run=TestAccAWSAPIGatewayDomainName_MutualTlsAuthentication'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayDomainName_MutualTlsAuthentication -timeout 120m
=== RUN   TestAccAWSAPIGatewayDomainName_MutualTlsAuthentication
=== PAUSE TestAccAWSAPIGatewayDomainName_MutualTlsAuthentication
=== CONT  TestAccAWSAPIGatewayDomainName_MutualTlsAuthentication
--- PASS: TestAccAWSAPIGatewayDomainName_MutualTlsAuthentication (151.06s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	151.102s
@ghost
Copy link

ghost commented Dec 12, 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 as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. partition/aws-us-gov Pertains to the aws-us-gov partition. provider Pertains to the provider itself, rather than any interaction with AWS. service/apigateway Issues and PRs that pertain to the apigateway service. size/L Managed by automation to categorize the size of a PR. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve aws_api_gateway_domain_name acceptance tests
2 participants