-
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
Add namevaluesfilters package for resource filtering code #13304
Comments
The code for data sources such as the // Filters based on attributes.
filters := namevaluesfilters.New(map[string]string{
"internet-gateway-id": d.Get("internet_gateway_id").(string),
})
// Filters based on keyvalue tags.
filters.Add(namevaluesfilters.Ec2Tags(keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()))
// Filters based on the custom filtering "filter" attribute.
filters.Add(d.Get("filter").(*schema.Set))
req.Filters = filters.Ec2Filters() |
Data sources (other than for EC2 resources) that can use this functionality:
|
Yes, it's effectively the same functionality although the |
I decided not to add the Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"values": {
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}, definition for the |
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. |
Community Note
Description
A number of AWS services, for example EC2 and RDS, support generic attribute filtering in APIs' resource
Describe
calls. The code to manipulate the data structures associated with resource filtering is nearly identical across services and is very amenable to code generation.Following on from this comment, it make senses to implement such generators in a new
namevaluesfilters
package.One possible interface is:
Definition of Done
namevaluesfilters
code generation for all relevant services with passing unit testsnamevaluesfilters
support for new servicesnamevaluefilters
in generated GetTags code: internal/keyvaluetags: Create {SERVICE}GetTag generator, support EC2 list/get, use in aws_ec2_tag implementation #13745, provider: Support arbitrary additional tag data, implement keyvaluetags and ignore_tags support in aws_autoscaling_group resource, return empty strings with key-only tags instead of panicking #13868aws/internal/service/ec2/filter.go
and open a linked issue if there is an opportunity for simplification/reuse/refactoringRelated:
The text was updated successfully, but these errors were encountered: