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

Fix aws_ec2_instance_connect_endpoint/fips_dns_name in non-US regions #37939

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

arax
Copy link

@arax arax commented Jun 12, 2024

Description

Outside of FIPS-supported regions (us-east-1, us-east-2, us-west-1, us-west-2, ca-central-1, ca-west-1, us-gov-east-1, us-gov-west-1) AWS API responses for EICE do not contain the FipsDnsName property. That leaves the resource in an infinite fips_dns_name = (known after apply) loop and results in crashes on apply.

This makes sure fips_dns_name is initialized with an empty string if the FipsDnsName property is missing from the AWS API response.

This does not change the resource's documented behavior or the behavior covered by tests.

Relations

Closes #37920

References

TestAcc Output

For us-east-1:

❯ make testacc TESTS=TestAccEC2InstanceConnectEndpoint PKG=ec2
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2InstanceConnectEndpoint'  -timeout 360m
=== RUN   TestAccEC2InstanceConnectEndpoint_basic
=== PAUSE TestAccEC2InstanceConnectEndpoint_basic
=== RUN   TestAccEC2InstanceConnectEndpoint_disappears
=== PAUSE TestAccEC2InstanceConnectEndpoint_disappears
=== RUN   TestAccEC2InstanceConnectEndpoint_tags
=== PAUSE TestAccEC2InstanceConnectEndpoint_tags
=== RUN   TestAccEC2InstanceConnectEndpoint_securityGroupIDs
=== PAUSE TestAccEC2InstanceConnectEndpoint_securityGroupIDs
=== CONT  TestAccEC2InstanceConnectEndpoint_basic
=== CONT  TestAccEC2InstanceConnectEndpoint_tags
=== CONT  TestAccEC2InstanceConnectEndpoint_securityGroupIDs
=== CONT  TestAccEC2InstanceConnectEndpoint_disappears
--- PASS: TestAccEC2InstanceConnectEndpoint_basic (388.42s)
--- PASS: TestAccEC2InstanceConnectEndpoint_securityGroupIDs (400.28s)
--- PASS: TestAccEC2InstanceConnectEndpoint_disappears (414.18s)
--- PASS: TestAccEC2InstanceConnectEndpoint_tags (1116.57s)
PASS
ok    [github.com/hashicorp/terraform-provider-aws/internal/service/ec2](http://github.com/hashicorp/terraform-provider-aws/internal/service/ec2)  1124.303s

For eu-west-1:

❯ make testacc TESTS=TestAccEC2InstanceConnectEndpoint PKG=ec2
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ec2/... -v -count 1 -parallel 20 -run='TestAccEC2InstanceConnectEndpoint'  -timeout 360m
=== RUN   TestAccEC2InstanceConnectEndpoint_basic
=== PAUSE TestAccEC2InstanceConnectEndpoint_basic
=== RUN   TestAccEC2InstanceConnectEndpoint_disappears
=== PAUSE TestAccEC2InstanceConnectEndpoint_disappears
=== RUN   TestAccEC2InstanceConnectEndpoint_tags
=== PAUSE TestAccEC2InstanceConnectEndpoint_tags
=== RUN   TestAccEC2InstanceConnectEndpoint_securityGroupIDs
=== PAUSE TestAccEC2InstanceConnectEndpoint_securityGroupIDs
=== CONT  TestAccEC2InstanceConnectEndpoint_basic
=== CONT  TestAccEC2InstanceConnectEndpoint_tags
=== CONT  TestAccEC2InstanceConnectEndpoint_securityGroupIDs
=== CONT  TestAccEC2InstanceConnectEndpoint_disappears
=== NAME  TestAccEC2InstanceConnectEndpoint_securityGroupIDs
    ec2_instance_connect_endpoint_test.go:138: Step 1/2 error: Check failed: Check 5/14 error: aws_ec2_instance_connect_endpoint.test: Attribute 'fips_dns_name' expected to be set
=== NAME  TestAccEC2InstanceConnectEndpoint_basic
    ec2_instance_connect_endpoint_test.go:29: Step 1/2 error: Check failed: Check 5/12 error: aws_ec2_instance_connect_endpoint.test: Attribute 'fips_dns_name' expected to be set
--- FAIL: TestAccEC2InstanceConnectEndpoint_securityGroupIDs (372.20s)
--- FAIL: TestAccEC2InstanceConnectEndpoint_basic (373.07s)
--- PASS: TestAccEC2InstanceConnectEndpoint_disappears (379.99s)
--- PASS: TestAccEC2InstanceConnectEndpoint_tags (1098.51s)
FAIL
FAIL  [github.com/hashicorp/terraform-provider-aws/internal/service/ec2](http://github.com/hashicorp/terraform-provider-aws/internal/service/ec2)  1107.920s
FAIL
make: *** [testacc] Error 1

Copy link

Community Note

Voting for Prioritization

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

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XS Managed by automation to categorize the size of a PR. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jun 12, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 12, 2024
@arax arax marked this pull request as ready for review June 12, 2024 18:41
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @arax 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@arax
Copy link
Author

arax commented Jun 12, 2024

Q: I'm wondering how to properly write acc tests for behavior that depends on specific AWS regions being selected for the test. As shown above in the testacc output, us-east-1 still works as it worked before. eu-west-1 is still broken as it was broken before. Should I just relax the test criteria and check for a non-null value?

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: aws_ec2_instance_connect_endpoint known after apply issue for fips_dns_name
2 participants