list-resource/aws_vpc: Reduces API calls when listing#46935
list-resource/aws_vpc: Reduces API calls when listing#46935
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
| results := make(map[string]*awstypes.RouteTable, len(output)) | ||
| for i, v := range output { | ||
| results[aws.ToString(v.VpcId)] = &output[i] | ||
| } |
There was a problem hiding this comment.
This seems like it will overwrite the map entry for each route table in the result. Should this instead check for the key in result and append if already exists?
Edit: I see now the only current call to this function is from batchFindVPCMainRouteTables where we know the result will be limited to a single item per VPC, but it may still be worth future proofing should we reach for this in the future for batch listing all route tables and grouping by VPC.
| results := make(map[string]*awstypes.SecurityGroup, len(output)) | ||
| for i, v := range output { | ||
| results[aws.ToString(v.VpcId)] = &output[i] | ||
| } |
There was a problem hiding this comment.
Same for iterating security group results (multiple per VPC).
| results := make(map[string]*awstypes.NetworkAcl, len(output)) | ||
| for i, v := range output { | ||
| results[aws.ToString(v.VpcId)] = &output[i] | ||
| } |
There was a problem hiding this comment.
Same for iterating network ACLs (one per subnet, but a VPC may have multiple).
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
Reduces AWS API calls when listing by:
Relations
Closes #46724
Output from Acceptance Testing