-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
d/aws_route53_resolver_endpoint: Add Route53resolver endpoint datasource #8628
Conversation
@robh007 Do you have cycles to fix the merge conflicts on this one? |
@ewbankkit Sure, I should be able to resolve these tomorrow. |
@robh007 any chance you could get this conflict sorted? would love to have this in the official provider! |
@Omarimcblack Yes sure, I'll try and sort today. |
323f63e
to
4f69640
Compare
"github.com/aws/aws-sdk-go/service/route53resolver" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/hashicorp/terraform/helper/schema" |
There was a problem hiding this comment.
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"
Notification of Recent and Upcoming Changes to ContributionsThank 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 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 SyntaxReference: #8950 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 ( Action Required: Terraform Plugin SDK Version 2Reference: #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 FileReference: #14712 Any changes to the Upcoming Change of Git Branch NamingReference: #14292 Development environments will need their upstream Git branch updated from Upcoming Change of GitHub OrganizationReference: #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 |
@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? |
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
@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. |
4f69640
to
a3b3aa2
Compare
|
||
```hcl | ||
data "aws_route53_resolver_endpoint" "example" { | ||
id = "rslvr-in-1abc2345ef678g91h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id = "rslvr-in-1abc2345ef678g91h" | |
resolver_endpoint_id = "rslvr-in-1abc2345ef678g91h" |
|
||
## Argument Reference | ||
|
||
* `id` - (Optional) The ID of the Route53 Resolver Endpoint. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `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" {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use testAccAvailableAZsNoOptInConfig
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)
There was a problem hiding this comment.
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.
--- PASS: TestAccDataSourceAwsRoute53ResolverEndpoint_Basic (138.65s) |
tags = { | ||
Name = "tf-acc-r53-resolver-sn1-%d" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 4.
tags = { | |
Name = "tf-acc-r53-resolver-sn1-%d" | |
} | |
tags = { | |
Name = "tf-acc-r53-resolver-sn1-%d" | |
} |
tags = { | ||
Name = "tf-acc-r53-resolver-sn3-%d" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 4.
tags = { | |
Name = "tf-acc-r53-resolver-sn3-%d" | |
} | |
tags = { | |
Name = "tf-acc-r53-resolver-sn3-%d" | |
} |
tags = { | ||
Name = "tf-acc-r53-resolver-sg2-%d" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 4.
tags = { | |
Name = "tf-acc-r53-resolver-sg2-%d" | |
} | |
tags = { | |
Name = "tf-acc-r53-resolver-sg2-%d" | |
} |
tags = { | ||
Name = "tf-acc-r53-resolver-sg1-%d" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 5.
tags = { | |
Name = "tf-acc-r53-resolver-sg1-%d" | |
} | |
tags = { | |
Name = "tf-acc-r53-resolver-sg1-%d" | |
} |
data "aws_route53_resolver_endpoint" "foo" { | ||
resolver_endpoint_id = aws_route53_resolver_endpoint.foo.id | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 4.
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 | |
} |
data "aws_route53_resolver_endpoint" "foo" { | ||
filter { | ||
name = "Name" | ||
values = [aws_route53_resolver_endpoint.foo.name] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 4.
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] | |
} |
data "aws_route53_resolver_endpoint" "foo" { | ||
filter { | ||
name = "Name" | ||
values = ["None-Existent-Resource"] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 4.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 spaces, not 3.
depends_on = [aws_route53_resolver_endpoint.foo] | |
depends_on = [aws_route53_resolver_endpoint.foo] |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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]
}
}
@robh007 Thanks for sticking with this. |
filter { | ||
name = "SecurityGroupIds" | ||
values = [aws_security_group.sg1.id, aws_security_group.sg2.id] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment.
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] | |
} |
filter { | ||
name = "Name" | ||
values = ["None-Existent-Resource"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alignment.
filter { | |
name = "Name" | |
values = ["None-Existent-Resource"] | |
} | |
filter { | |
name = "Name" | |
values = ["None-Existent-Resource"] | |
} |
There was a problem hiding this 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
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``` |
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! |
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! |
Route53resolver endpoint data source with filter & ID support
Community Note
Fixes #8355
Release note for CHANGELOG:
Output from acceptance testing: