-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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_network_interface: Add filter attribute #2851
Conversation
33651af
to
74907d6
Compare
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 @Gufran for this contribution! Check out the comments below and see if they make sense. Please let me know if you have any questions or when to check this again. 👍
filters, filtersOk := d.GetOk("filter") | ||
id, idOk := d.GetOk("id") | ||
if idOk && filtersOk { | ||
return fmt.Errorf("Only one of filter or id can be assigned") |
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.
Is there a technical reason for this limitation?
- If both
id
andfilter
are supplied and the filter successfully matches the resource corresponding to the ID, its okay and the data source will return the one result. - If both
id
andfilter
are supplied and the filter doesn't successfully match the resource corresponding to the ID, the data source will return the error. - Folks might want to create a module with this data source and toggle between both attributes. HCL doesn't support a
nil
value at the moment so this would prevent that use case.
} | ||
|
||
input := &ec2.DescribeNetworkInterfacesInput{} | ||
if idOk { |
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.
We should probably check to ensure ID actually has a value if idOk && id.(string) != "" {
security_groups = ["${aws_security_group.test.id}"] | ||
} | ||
|
||
data "aws_network_interface" "test" { |
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.
This needs depends_on = ["aws_network_interface.test"]
otherwise it fails due to dependency ordering:
--- FAIL: TestAccDataSourceAwsNetworkInterface_filters (47.96s)
testing.go:503: Step 0 error: Error applying: 1 error(s) occurred:
* data.aws_network_interface.test: data.aws_network_interface.test: no matching network interface found
`, rName) | ||
} | ||
|
||
func TestAccDataSourceAwsNetworkInterface_error_exclusive(t *testing.T) { |
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.
This test and its configuration can be removed given above comment.
* `id` – (Optional) The identifier for the network interface. | ||
* `filter` – (Optional) One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-network-interfaces](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-network-interfaces.html) in the AWS CLI reference. | ||
|
||
~> **NOTE:** Either `id` or `filter` must be specified. Both `id` and `filter` cannot be specified together. |
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.
This note can be removed given above comment.
74907d6
to
d70c1b9
Compare
@bflad I made the changes. and I'm sorry about the problem with tests, not sure if there is a way for me to run tests locally without racking up a bill on AWS. |
…-interface-id filter in testing
Since you weren't able to run them, I made some minor adjustments to make the acceptance testing happy consistently (mainly setting
|
This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
No description provided.