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

data-source/aws_route53_zone: Perform NS record lookup for private Hosted Zones #17002

Merged
merged 2 commits into from
Jan 27, 2021

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 6, 2021

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

Closes #10391
Closes #16862

Release note for CHANGELOG:

NOTES

* data-source/aws_route53_zone: The Route 53 `ListResourceRecordSets` API call has been implemented to support the `name_servers` attribute for private Hosted Zones similar to the resource implementation. Environments using restrictive IAM permissions may require updates.

BUG FIXES

* data-source/aws_route53_zone: Ensure `name_servers` is populated for private Hosted Zones

Previously after testing updates:

=== CONT  TestAccAWSRoute53ZoneDataSource_vpc
    data_source_aws_route53_zone_test.go:89: Step 1/1 error: Check failed: Check 3/4 error: aws_route53_zone.test: Attribute "name_servers.#" is "4", but "name_servers.#" is not set in data.aws_route53_zone.test
--- FAIL: TestAccAWSRoute53ZoneDataSource_vpc (83.04s)

Output from acceptance testing:

--- PASS: TestAccAWSRoute53ZoneDataSource_id (46.24s)
--- PASS: TestAccAWSRoute53ZoneDataSource_name (47.24s)
--- PASS: TestAccAWSRoute53ZoneDataSource_tags (94.61s)
--- PASS: TestAccAWSRoute53ZoneDataSource_vpc (94.63s)
--- PASS: TestAccAWSRoute53ZoneDataSource_serviceDiscovery (110.28s)

…sted Zones

Reference: #10391
Reference: #16862

Changes:

```
NOTES

* data-source/aws_route53_zone: The Route 53 `ListResourceRecordSets` API call has been implemented to support the `name_servers` attribute for private Hosted Zones similar to the resource implementation. Environments using restrictive IAM permissions may require updates.

BUG FIXES

* data-source/aws_route53_zone: Ensure `name_servers` is populated for private Hosted Zones
```

Previously after testing updates:

```
=== CONT  TestAccAWSRoute53ZoneDataSource_vpc
    data_source_aws_route53_zone_test.go:89: Step 1/1 error: Check failed: Check 3/4 error: aws_route53_zone.test: Attribute "name_servers.#" is "4", but "name_servers.#" is not set in data.aws_route53_zone.test
--- FAIL: TestAccAWSRoute53ZoneDataSource_vpc (83.04s)
```

Output from acceptance testing:

```
--- PASS: TestAccAWSRoute53ZoneDataSource_id (46.24s)
--- PASS: TestAccAWSRoute53ZoneDataSource_name (47.24s)
--- PASS: TestAccAWSRoute53ZoneDataSource_tags (94.61s)
--- PASS: TestAccAWSRoute53ZoneDataSource_vpc (94.63s)
--- PASS: TestAccAWSRoute53ZoneDataSource_serviceDiscovery (110.28s)
```
@bflad bflad added the bug Addresses a defect in current functionality. label Jan 6, 2021
@bflad bflad requested a review from a team as a code owner January 6, 2021 18:43
@ghost ghost added size/S Managed by automation to categorize the size of a PR. service/route53 Issues and PRs that pertain to the route53 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 6, 2021
Base automatically changed from master to main January 23, 2021 01:00
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

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

Optional nits but LGTM! 🎉

GovCloud:

--- PASS: TestAccAWSRoute53ZoneDataSource_tags (68.32s)
--- PASS: TestAccAWSRoute53ZoneDataSource_vpc (66.51s)
--- SKIP: TestAccAWSRoute53ZoneDataSource_id (6.86s)
--- SKIP: TestAccAWSRoute53ZoneDataSource_name (7.25s)
--- SKIP: TestAccAWSRoute53ZoneDataSource_serviceDiscovery (1.26s)

us-west-2:

--- PASS: TestAccAWSRoute53ZoneDataSource_name (45.95s)
--- PASS: TestAccAWSRoute53ZoneDataSource_id (46.08s)
--- PASS: TestAccAWSRoute53ZoneDataSource_vpc (82.93s)
--- PASS: TestAccAWSRoute53ZoneDataSource_tags (83.90s)
--- PASS: TestAccAWSRoute53ZoneDataSource_serviceDiscovery (118.57s)

if err != nil {
return fmt.Errorf("Error finding Route 53 Hosted Zone: %v", err)
return fmt.Errorf("error getting Route 53 Hosted Zone (%s) name servers: %w", idHostedZone, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("error getting Route 53 Hosted Zone (%s) name servers: %w", idHostedZone, err)
return fmt.Errorf("getting Route 53 Hosted Zone (%s) name servers: %w", idHostedZone, err)

Nit: not a fan of Error: error getting... that this would produce.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for raising this. Rather than leaving a lengthy comment that could be lost about the history of this, I have created #17314 with all the information. What is important right now is that fmt.Errorf("error creating/reading/updating/deleting Service Thing (ID): Error") is the (finally now 😖 ) documented practice for consistency that's been the goal last few years, which is showing its age in Terraform 0.12 and later. I would rather continue the existing practice for later find/replace-ability until we can decide as a team on any potential new standards.

Please feel free to check that out issue and contribute!

if err := d.Set("name_servers", nameServers); err != nil {
return fmt.Errorf("error setting name_servers: %w", err)
}

tags, err = keyvaluetags.Route53ListTags(conn, idHostedZone, route53.TagResourceTypeHostedzone)

if err != nil {
return fmt.Errorf("Error finding Route 53 Hosted Zone: %v", err)
return fmt.Errorf("error listing Route 53 Hosted Zone (%s) tags: %w", idHostedZone, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("error listing Route 53 Hosted Zone (%s) tags: %w", idHostedZone, err)
return fmt.Errorf("failed listing Route 53 Hosted Zone (%s) tags: %w", idHostedZone, err)

Another approach.

}

if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
return fmt.Errorf("error setting tags: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("error setting tags: %w", err)
return fmt.Errorf("setting tags: %w", err)

if err != nil {
return []string{}, err
return nil, fmt.Errorf("error getting Route 53 Hosted Zone (%s): %w", id, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("error getting Route 53 Hosted Zone (%s): %w", id, err)
return nil, fmt.Errorf("getting Route 53 Hosted Zone (%s): %w", id, err)

}

if output == nil {
return nil, fmt.Errorf("error getting Route 53 Hosted Zone (%s): empty response", id)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("error getting Route 53 Hosted Zone (%s): empty response", id)
return nil, fmt.Errorf("getting Route 53 Hosted Zone (%s): empty response", id)

nameServers, err := getNameServers(id, name, conn)

if err != nil {
return nil, fmt.Errorf("error listing Route 53 Hosted Zone (%s) NS records: %w", id, err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("error listing Route 53 Hosted Zone (%s) NS records: %w", id, err)
return nil, fmt.Errorf("listing Route 53 Hosted Zone (%s) NS records: %w", id, err)

@bflad bflad merged commit 0939a74 into main Jan 27, 2021
@bflad bflad deleted the b-aws_route53_zone-name_servers branch January 27, 2021 17:53
@github-actions github-actions bot added this to the v3.26.0 milestone Jan 27, 2021
github-actions bot pushed a commit that referenced this pull request Jan 27, 2021
@ghost
Copy link

ghost commented Jan 28, 2021

This has been released in version 3.26.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 Feb 27, 2021

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 Feb 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/route53 Issues and PRs that pertain to the route53 service. size/S 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
Development

Successfully merging this pull request may close these issues.

Can't get Name Servers with aws_route53_zone data Empty name_servers in datasource aws_route53_zone
2 participants