🤖🤖🤖 d/aws_dx_connections: New data source - #49151
Open
BenjaminSaintCyr wants to merge 3 commits into
Open
Conversation
Adds a plural data source returning every Direct Connect connection in the Region, for the common case of iterating connections without knowing their names up front. Also makes findConnections paginate. It is shared by the aws_dx_connection data source and resource, so this fixes silent truncation past 100 connections for those two as well. Closes hashicorp#40032
Contributor
|
✅ Thank you for correcting the previously detected issues! The maintainers appreciate your efforts to make the review process as smooth as possible. |
Contributor
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
|
Use names.Attr* and acctest.Ct* constants for attribute-name literals, extract the unit-test fixture Regions into lintignore:AWSAT003 constants, rename TestFlattenConnectionsTagsIgnoreAWS, and mark flattenConnections nosemgrep with the reason AutoFlex cannot cover the ARN and tags fields.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
No. This PR adds a read-only data source only. It requires no IAM permissions beyond
directconnect:DescribeConnections, which the existingaws_dx_connectiondata source already needs.Description
Adds a new plural data source
aws_dx_connectionsthat returns every Direct Connect connection in the Region. The singularaws_dx_connectiondata source requires knowing a connection name up front and errors unless exactly one matches, so there is currently no way to enumerate connections.connections, a list of objects each carryingarn,aws_device,bandwidth,id,location,name,owner_account_id,partner_name,provider_name,state,tags, andvlan_id.DescribeConnectionshas no server-side filter (its input accepts only a single connection ID), so callers filter in configuration with afor/for_eachexpression.findConnectionspaginate, which affects two pre-existing callers.DescribeConnectionsis not modelled as paginated in the SDK but does return anextToken, and the previous implementation read only the first page. This also fixes silent truncation past 100 connections for theaws_dx_connectiondata source and resource — a behaviour change beyond the scope the title implies, called out here rather than left in the diff.id, per the data-source naming guidance; each element carries its ownid(the connection ID). A unit test pins this so it cannot regress.aws_deviceis populated from the API'sawsDeviceV2field, sinceawsDeviceis deprecated and empty in practice. The model field is namedAwsDeviceV2so AutoFlex binds the correct one, while the public attribute name staysaws_deviceto match the singular data source.connectionsstays usable infor_eachwithouttry/coalesce. Likewise an untagged connection flattenstagsto an empty map rather than null.terraform-plugin-framework+aws-sdk-go-v2, with AutoFlex (fwflex.Flatten) for the per-item conversion andframework.DataSourceComputedListOfObjectAttributefor the nested schema.Relations
Closes #40032
References
DescribeConnections: https://docs.aws.amazon.com/directconnect/latest/APIReference/API_DescribeConnections.htmlDescribeConnections: https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/directconnect#Client.DescribeConnectionsConnectiontype: https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/directconnect/types#Connectioninternal/service/directconnect/connection_data_source.gofindConnectionsininternal/service/directconnect/connection.goOutput from Acceptance Testing
Run in
us-west-2withAWS_ALTERNATE_REGION=us-east-1, since the_emptyand_regiontests callacctest.PreCheckMultipleRegion(t, 2). The tests create and destroy real connections; they need no cross-connect or physical hardware, and a connection left inrequestedstate accrues no port-hours.Unit tests additionally cover pagination across page boundaries, the element-attribute contract, and the empty-list/empty-map flattening, with no credentials required:
golangci-lintis clean across all five.ci/.golangci*.ymlconfigs,semgrepis clean for the constants, naming and code-quality configs,providerlintis clean,swissshepherdreportsAll checks passed.for both documentation pages, andgo generate ./internal/service/directconnect/reproduces the generated files byte-for-byte.AI Usage Disclosure
This pull request was prepared with assistance from an AI agent — specifically, a custom agent running inside Claude Code. The agent was configured for this repository (branching conventions,
make genawareness, no manual edits to_gen.go, smarterr patterns, AutoFlex, Framework patterns, acceptance-test scaffolding) and used for code generation, test authoring, and documentation. Every line has been reviewed by the human contributor, who has verified the code compiles and understands each design decision. Per the project's AI Usage Policy, "🤖🤖🤖" is included in the PR title.