New data source: aws_bedrockagentcore_gateway_rate_limit - #49440
Open
tobydoescode wants to merge 6 commits into
Open
New data source: aws_bedrockagentcore_gateway_rate_limit#49440tobydoescode wants to merge 6 commits into
tobydoescode wants to merge 6 commits into
Conversation
Manages rate limits on a Bedrock AgentCore Gateway, throttling requests, tokens and concurrent connections per dimension. Closes hashicorp#49344. A gateway may have up to 50 rate limits, each keyed by a unique, immutable ordered list of dimension_keys, so this maps 1:1 with one GatewayRateLimit rather than collapsing them into a gateway-level resource. Schema notes: * dimension_keys is a list, not a set: ordering is load-bearing, since a "*" wildcard is only legal in trailing positions. Immutable, so RequiresReplace. * entries is a set: the gateway matches by computed specificity, so wire order carries no meaning. * Two plan-time cross-field validators enforce what the type system cannot - that an entry's dimensions keys match dimension_keys exactly, and that wildcards appear only in trailing positions. Dimension keys are validated by regex rather than an enum, because the $.context.jwt.<claim> arm admits any claim name. * rate is Float64: the API accepts fractional rates. rate = 0 is meaningful and blocks all matching traffic. * tokens accepts only period "minute" and connections only "second"; requests accepts both. Verified against the live API. * description is Optional but not Computed. Unlike UpdateGatewayRule, this API treats an omitted description as "clear it", so removing the argument removes the value. Create, Update and Delete take the same per-gateway mutex as aws_bedrockagentcore_gateway_rule, since the service holds its lock on the gateway rather than the child, and retry on ConflictException. Note that creating two rate limits with the same dimension_keys returns ValidationException, not the ConflictException documented in the AgentCore developer guide. An acceptance test pins this. Acceptance tests (us-west-2): --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_basic --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_disappears --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_duplicateDimensionKeys --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_forceNew --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_multipleLimits --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_update --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_wildcards --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_Identity_basic --- PASS: TestAccBedrockAgentCoreGatewayRateLimit_Identity_regionOverride
% make testacc PKG=bedrockagentcore TESTS=TestAccBedrockAgentCoreGatewayRateLimitDataSource_ make: Verifying source code with gofmt... ==> Checking that code complies with gofmt requirements... make: Validating schemas ok github.com/hashicorp/terraform-provider-aws/internal/provider/sdkv2 6.995s ok github.com/hashicorp/terraform-provider-aws/internal/provider/framework 7.061s make: Running acceptance tests on branch: 🌿 f-aws_bedrockagentcore_gateway_rate_limit-data-source 🌿... TF_ACC=1 go1.26.5 test ./internal/service/bedrockagentcore/... -v -count 1 -parallel 20 -run='TestAccBedrockAgentCoreGatewayRateLimitDataSource_' -timeout 360m -vet=off -buildvcs=false 2026/08/12 20:14:44 Creating Terraform AWS Provider (SDKv2-style)... 2026/08/12 20:14:44 Initializing Terraform AWS Provider (SDKv2-style)... === RUN TestAccBedrockAgentCoreGatewayRateLimitDataSource_basic === PAUSE TestAccBedrockAgentCoreGatewayRateLimitDataSource_basic === RUN TestAccBedrockAgentCoreGatewayRateLimitDataSource_notFound === PAUSE TestAccBedrockAgentCoreGatewayRateLimitDataSource_notFound === CONT TestAccBedrockAgentCoreGatewayRateLimitDataSource_basic === CONT TestAccBedrockAgentCoreGatewayRateLimitDataSource_notFound --- PASS: TestAccBedrockAgentCoreGatewayRateLimitDataSource_notFound (19.30s) --- PASS: TestAccBedrockAgentCoreGatewayRateLimitDataSource_basic (30.62s) PASS ok github.com/hashicorp/terraform-provider-aws/internal/service/bedrockagentcore 39.460s
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
|
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 changes to security controls. This adds a read-only data source.
Description
Important
This PR depends on #49429 and should be reviewed after it merges.
The resource and data source are deliberately split across two pull requests, following
docs/add-a-new-datasource.md:#49429 adds the
aws_bedrockagentcore_gateway_rate_limitresource; this PR adds the matchingdata source.
Why the diff below is larger than this change. The data source branch is stacked on the
resource branch, and a cross-repo pull request cannot be based on a branch that exists only in the
fork — so GitHub shows both sets of commits here. Only the six files listed below belong to this
PR.
The split cannot be avoided by reordering. The data source genuinely depends on the resource:
its
ReadcallsfindGatewayRateLimitByTwoPartKey, defined ingateway_rate_limit.go, and its_basicacceptance test creates a rate limit in order to read one back. I verified this byrebasing onto
mainin a scratch worktree — the rebase applies with no conflicts, then fails tobuild with
undefined: findGatewayRateLimitByTwoPartKey. Decoupling would mean duplicating thefinder or bypassing it, both of which make the merged result worse.
Once #49429 merges I will rebase this branch onto
main, and the diff will reduce to the sixfiles below. Happy to close and reopen instead if that is preferred.
Adds
aws_bedrockagentcore_gateway_rate_limit, looking up a single rate limit on a Bedrock AgentCore Gateway by its identifier. This is the first data source in thebedrockagentcoreservice.Files belonging to this change:
internal/service/bedrockagentcore/gateway_rate_limit_data_source.gointernal/service/bedrockagentcore/gateway_rate_limit_data_source_test.gointernal/service/bedrockagentcore/testdata/GatewayRateLimitDataSource/{basic,not_found}/main.tfwebsite/docs/d/bedrockagentcore_gateway_rate_limit.html.markdown.changelog/49440.txtTwo deliberate divergences from the resource, both noted in the data source documentation so they do not read as oversights:
entriesis a computed list attribute rather than a nested block.docs/add-a-new-datasource.mdrequiresframework.DataSourceComputedListOfObjectAttributefor objects with only computed attributes, since fully computed blocks are not supported by Terraform protocol V6.status,created_atandupdated_atare exported here but omitted on the resource, where a transient status would be state noise — the resource's waiters exist so practitioners never need to inspect it.aws_bedrock_inference_profileexposes all three on its data source.Lookup is by
rate_limit_idonly, mirroringGetGatewayRateLimit. Adimension_keyslookup is also possible in principle, since that tuple is unique per gateway, but it would need a second code path over paginatedListGatewayRateLimitswith order-sensitive client-side matching. It can be added later without breaking anyone.Relations
Relates #49344
Depends on #49429
References
Output from Acceptance Testing
The resource's nine acceptance tests also still pass on top of this branch:
Run in
us-west-2with Terraform v1.15.8.