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

d/aws_route53_resolver_endpoint: Add Route53resolver endpoint datasource #8628

Merged
merged 8 commits into from
Nov 5, 2020

Conversation

robh007
Copy link
Contributor

@robh007 robh007 commented May 14, 2019

Route53resolver endpoint data source with filter & ID support

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #8355

Release note for CHANGELOG:

** New Data Source:** `aws_route53_resolver_endpoint`

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccDataSourceAwsRoute53ResolverEndpoint'
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (118.34s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (295.04s)
...

@ghost ghost added size/XL 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. service/route53 Issues and PRs that pertain to the route53 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels May 14, 2019
@bflad bflad added new-data-source Introduces a new data source. service/route53resolver Issues and PRs that pertain to the route53resolver service. and removed service/route53 Issues and PRs that pertain to the route53 service. labels May 14, 2019
@aeschright aeschright requested a review from a team June 26, 2019 16:53
@ewbankkit
Copy link
Contributor

@robh007 Do you have cycles to fix the merge conflicts on this one?

@robh007
Copy link
Contributor Author

robh007 commented Aug 11, 2019

@ewbankkit Sure, I should be able to resolve these tomorrow.

@Omarimcblack
Copy link
Contributor

@robh007 any chance you could get this conflict sorted? would love to have this in the official provider!

@ALLFIVE
Copy link

ALLFIVE commented Jan 6, 2020

@Omarimcblack Yes sure, I'll try and sort today.

@robh007 robh007 force-pushed the route53-resolver-endpoint branch from 323f63e to 4f69640 Compare January 7, 2020 10:41
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. and removed size/XL Managed by automation to categorize the size of a PR. labels Jan 7, 2020
"github.com/aws/aws-sdk-go/service/route53resolver"

"github.com/aws/aws-sdk-go/aws"
"github.com/hashicorp/terraform/helper/schema"
Copy link
Contributor

Choose a reason for hiding this comment

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

hey @robh007 just a heads up this has now changed to "github.com/hashicorp/terraform-plugin-sdk/helper/schema"

@teamterraform
Copy link

Notification of Recent and Upcoming Changes to Contributions

Thank you for this contribution! There have been a few recent development changes that affect this pull request. We apologize for the inconvenience, especially if there have been long review delays up until now. Please note that this is automated message from an unmonitored account. See the FAQ for additional information on the maintainer team and review prioritization.

If you are unable to complete these updates, please leave a comment for the community and maintainers so someone can potentially continue the work. The maintainers will encourage other contributors to use the existing contribution as the base for additional changes as appropriate. Otherwise, contributions that do not receive updated code or comments from the original contributor may be closed in the future so the maintainers can focus on active items.

For the most up to date information about Terraform AWS Provider development, see the Contributing Guide. Additional technical debt changes can be tracked with the technical-debt label on issues.

As part of updating a pull request with these changes, the most current unit testing and linting will run. These may report issues that were not previously reported.

Action Required: Terraform 0.12 Syntax

Reference: #8950
Reference: #14417

Version 3 and later of the Terraform AWS Provider, which all existing contributions would potentially be added, only supports Terraform 0.12 and later. Certain syntax elements of Terraform 0.11 and earlier show deprecation warnings during runs with Terraform 0.12. Documentation and test configurations, such as those including deprecated string interpolations (some_attribute = "${aws_service_thing.example.id}") should be updated to the newer syntax (some_attribute = aws_service_thing.example.id). Contribution testing will automatically fail on older syntax in the near future. Please see the referenced issues for additional information.

Action Required: Terraform Plugin SDK Version 2

Reference: #14551

The Terraform AWS Provider has been upgraded to the latest version of the Terraform Plugin SDK. Generally, most changes to contributions should only involve updating Go import paths in source code files. Please see the referenced issue for additional information.

Action Required: Removal of website/aws.erb File

Reference: #14712

Any changes to the website/aws.erb file are no longer necessary and should be removed from this contribution to prevent merge issues in the near future when the file is removed from the repository. Please see the referenced issue for additional information.

Upcoming Change of Git Branch Naming

Reference: #14292

Development environments will need their upstream Git branch updated from master to main in the near future. Please see the referenced issue for additional information and scheduling.

Upcoming Change of GitHub Organization

Reference: #14715

This repository will be migrating from https://github.com/terraform-providers/terraform-provider-aws to https://github.com/hashicorp/terraform-provider-aws. No practitioner or developer action is anticipated and most GitHub functionality will automatically redirect to the new location. Go import paths including terraform-providers can remain for now. Please see the referenced issue for additional information and scheduling.

@ewbankkit
Copy link
Contributor

@robh007 Thanks for all the work on this contribution. Are you able to make all the changes described above for the Plugin SDK v2 migration?
If not, I am happy to add to your work and get this merged.

@ewbankkit ewbankkit added the waiting-response Maintainers are waiting on response from community or contributor. label Oct 26, 2020
Fixed typo in docs for resource_status to be status

Changed approach & tried to incorperate Filter & ID

Initial route53resolver data source with filter & ID support

Typo in Documentation

Resolving conflicts
@robh007
Copy link
Contributor Author

robh007 commented Oct 26, 2020

@ewbankkit I’ve updated the code locally, just having an issue with the filter test. Looks like AWS have made some changes to the api. Can’t see why it’s failing at the moment. I’ll push up my changes tomorrow.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Oct 26, 2020
@robh007 robh007 force-pushed the route53-resolver-endpoint branch from 4f69640 to a3b3aa2 Compare October 28, 2020 09:57
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/XXL Managed by automation to categorize the size of a PR. labels Oct 28, 2020

```hcl
data "aws_route53_resolver_endpoint" "example" {
id = "rslvr-in-1abc2345ef678g91h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
id = "rslvr-in-1abc2345ef678g91h"
resolver_endpoint_id = "rslvr-in-1abc2345ef678g91h"


## Argument Reference

* `id` - (Optional) The ID of the Route53 Resolver Endpoint.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `id` - (Optional) The ID of the Route53 Resolver Endpoint.
* `resolver_endpoint_id` - (Optional) The ID of the Route53 Resolver Endpoint.

}
}

data "aws_availability_zones" "available" {}
Copy link
Contributor

@ewbankkit ewbankkit Oct 29, 2020

Choose a reason for hiding this comment

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

Use testAccAvailableAZsNoOptInConfig

https://github.com/terraform-providers/terraform-provider-aws/blob/aff071d49120c136dcb4917133b4eaa6512f0482/aws/resource_aws_instance_test.go#L3301-L3312

otherwise the default acceptance test regions may use Local Zone AZs and get errors like:

=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
    data_source_aws_route53_resolver_endpoint_test.go:19: Step 2/2 error: Error running apply: 2020/10/29 10:40:11 [DEBUG] Using modified User-Agent: Terraform/0.12.26 HashiCorp-terraform-exec/0.10.0
        
        Error: error creating Route53 Resolver endpoint: InvalidRequestException: [RSLVR-00419] There are no resolver resources in the Availability Zone containing subnet: "subnet-055bec065a57e028c"
        
        
--- FAIL: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (23.32s)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ewbankkit I'll get these resolved today.

@robh007 robh007 requested a review from a team as a code owner November 3, 2020 10:56
@robh007
Copy link
Contributor Author

robh007 commented Nov 3, 2020

--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (138.65s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (281.56s)
PASS

Comment on lines 85 to 87
tags = {
Name = "tf-acc-r53-resolver-sn1-%d"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

2 spaces, not 4.

Suggested change
tags = {
Name = "tf-acc-r53-resolver-sn1-%d"
}
tags = {
Name = "tf-acc-r53-resolver-sn1-%d"
}

Comment on lines 105 to 107
tags = {
Name = "tf-acc-r53-resolver-sn3-%d"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

2 spaces, not 4.

Suggested change
tags = {
Name = "tf-acc-r53-resolver-sn3-%d"
}
tags = {
Name = "tf-acc-r53-resolver-sn3-%d"
}

Comment on lines 123 to 125
tags = {
Name = "tf-acc-r53-resolver-sg2-%d"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

2 spaces, not 4.

Suggested change
tags = {
Name = "tf-acc-r53-resolver-sg2-%d"
}
tags = {
Name = "tf-acc-r53-resolver-sg2-%d"
}

Comment on lines 114 to 116
tags = {
Name = "tf-acc-r53-resolver-sg1-%d"
}
Copy link
Contributor

@ewbankkit ewbankkit Nov 3, 2020

Choose a reason for hiding this comment

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

2 spaces, not 5.

Suggested change
tags = {
Name = "tf-acc-r53-resolver-sg1-%d"
}
tags = {
Name = "tf-acc-r53-resolver-sg1-%d"
}

Comment on lines 156 to 158
data "aws_route53_resolver_endpoint" "foo" {
resolver_endpoint_id = aws_route53_resolver_endpoint.foo.id
}
Copy link
Contributor

Choose a reason for hiding this comment

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

2 spaces, not 4.

Suggested change
data "aws_route53_resolver_endpoint" "foo" {
resolver_endpoint_id = aws_route53_resolver_endpoint.foo.id
}
data "aws_route53_resolver_endpoint" "foo" {
resolver_endpoint_id = aws_route53_resolver_endpoint.foo.id
}

Comment on lines 188 to 192
data "aws_route53_resolver_endpoint" "foo" {
filter {
name = "Name"
values = [aws_route53_resolver_endpoint.foo.name]
}
Copy link
Contributor

@ewbankkit ewbankkit Nov 3, 2020

Choose a reason for hiding this comment

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

2 spaces, not 4.

Suggested change
data "aws_route53_resolver_endpoint" "foo" {
filter {
name = "Name"
values = [aws_route53_resolver_endpoint.foo.name]
}
data "aws_route53_resolver_endpoint" "foo" {
filter {
name = "Name"
values = [aws_route53_resolver_endpoint.foo.name]
}

Comment on lines 206 to 211
data "aws_route53_resolver_endpoint" "foo" {
filter {
name = "Name"
values = ["None-Existent-Resource"]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

2 spaces, not 4.

Suggested change
data "aws_route53_resolver_endpoint" "foo" {
filter {
name = "Name"
values = ["None-Existent-Resource"]
}
}
data "aws_route53_resolver_endpoint" "foo" {
filter {
name = "Name"
values = ["None-Existent-Resource"]
}
}

values = [aws_route53_resolver_endpoint.foo.name]
}

depends_on = [aws_route53_resolver_endpoint.foo]
Copy link
Contributor

Choose a reason for hiding this comment

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

2 spaces, not 3.

Suggested change
depends_on = [aws_route53_resolver_endpoint.foo]
depends_on = [aws_route53_resolver_endpoint.foo]

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, remove the depends_on line otherwise I get:

=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
    data_source_aws_route53_resolver_endpoint_test.go:47: Step 2/2 error: After applying this test step and performing a `terraform refresh`, the plan was not empty.
        stdout
        
        
        An execution plan has been generated and is shown below.
        Resource actions are indicated with the following symbols:
         <= read (data resources)
        
        Terraform will perform the following actions:
        
          # data.aws_route53_resolver_endpoint.foo will be read during apply
          # (config refers to values not yet known)
         <= data "aws_route53_resolver_endpoint" "foo"  {
              + arn          = (known after apply)
              + direction    = (known after apply)
              + id           = (known after apply)
              + ip_addresses = (known after apply)
              + name         = (known after apply)
              + status       = (known after apply)
              + vpc_id       = (known after apply)
        
              + filter {
                  + name   = "Name"
                  + values = [
                      + "tf-acc-test-6750279126925066157",
                    ]
                }
            }
        
        Plan: 0 to add, 0 to change, 0 to destroy.
--- FAIL: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (243.61s)

Copy link
Contributor Author

@robh007 robh007 Nov 5, 2020

Choose a reason for hiding this comment

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

Thanks for your patience @ewbankkit, when I did this work last year I didn't have a depends_on within the filter test, but when I came back to pick this up after your initial review the filter test started to fail on the data lookup. Which I found slightly odd. The AWS api had since changed the filter values, I think initially they where uppercase. However when I read the docs & both case types are supported. When I added the depends_on the error went away. I assumed something as changed within terraform at this point & not the provider.

If I remove the depends_on I get the following output.

=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
    data_source_aws_route53_resolver_endpoint_test.go:47: Step 2/2 error: Error running pre-apply plan: 
        Error: Your query returned no results. Please change your search criteria and try again
        
        
--- FAIL: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (16.33s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (117.56s)
FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws       119.311s
FAIL

If I leave the depends_on in the test passes.

TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsRoute53ResolverEndpoint -timeout 120m
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (107.22s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (239.47s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       241.261s

Not sure where to go with this now, I noticed the name parameter is optional on the resource so I'm not sure if that causes a potential issue with the initial plan. If I add a second filter using SecurityGroupIds I don't see the failure.

TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsRoute53ResolverEndpoint -timeout 120m
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (118.19s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (250.14s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       252.067s
data "aws_route53_resolver_endpoint" "foo" {
    filter {
      name   = "Name"
      values = [aws_route53_resolver_endpoint.foo.name]
    }

    filter {
      name = "SecurityGroupIds"
      values = [aws_security_group.sg1.id, aws_security_group.sg2.id]
    }
}

@ewbankkit
Copy link
Contributor

@robh007 Thanks for sticking with this.
Just a few test formatting changes and the removal of depends_on and this should be good to go.

Comment on lines 194 to 197
filter {
name = "SecurityGroupIds"
values = [aws_security_group.sg1.id, aws_security_group.sg2.id]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Alignment.

Suggested change
filter {
name = "SecurityGroupIds"
values = [aws_security_group.sg1.id, aws_security_group.sg2.id]
}
filter {
name = "SecurityGroupIds"
values = [aws_security_group.sg1.id, aws_security_group.sg2.id]
}

Comment on lines 210 to 213
filter {
name = "Name"
values = ["None-Existent-Resource"]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Alignment.

Suggested change
filter {
name = "Name"
values = ["None-Existent-Resource"]
}
filter {
name = "Name"
values = ["None-Existent-Resource"]
}

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 (once formatting fixes are in).

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccDataSourceAwsRoute53ResolverEndpoint_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsRoute53ResolverEndpoint_ -timeout 120m
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (79.75s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (213.85s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	213.903s

@breathingdust
Copy link
Member

LGTM 🚀 Thanks @robh007 for the contribution!

Verified Acceptance Tests in Commercial (us-west-2)

make testacc TEST=./aws/ TESTARGS='-run=TestAccDataSourceAwsRoute53ResolverEndpoint_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsRoute53ResolverEndpoint_ -timeout 120m
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (87.92s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (219.58s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	221.158s

Verified Acceptance Tests in GovCloud (us-gov-west-1)

make testacc TEST=./aws/ TESTARGS='-run=TestAccDataSourceAwsRoute53ResolverEndpoint_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccDataSourceAwsRoute53ResolverEndpoint_ -timeout 120m
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== RUN   TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== PAUSE TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Basic
=== CONT  TestAccDataSourceAwsRoute53ResolverEndpoint_Filter
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (71.55s)
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Filter (174.82s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	176.390s```

@breathingdust breathingdust added this to the v3.14.0 milestone Nov 5, 2020
@breathingdust breathingdust merged commit 4754d12 into hashicorp:master Nov 5, 2020
breathingdust added a commit that referenced this pull request Nov 5, 2020
@ghost
Copy link

ghost commented Nov 6, 2020

This has been released in version 3.14.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 Dec 6, 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 6, 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. new-data-source Introduces a new data source. provider Pertains to the provider itself, rather than any interaction with AWS. service/route53resolver Issues and PRs that pertain to the route53resolver service. size/XL 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.

Feature Request: aws_route53_resolver_endpoint data source
8 participants