Skip to content

New data source: aws_bedrockagentcore_gateway_rate_limit - #49440

Open
tobydoescode wants to merge 6 commits into
hashicorp:mainfrom
tobydoescode:f-aws_bedrockagentcore_gateway_rate_limit-data-source
Open

New data source: aws_bedrockagentcore_gateway_rate_limit#49440
tobydoescode wants to merge 6 commits into
hashicorp:mainfrom
tobydoescode:f-aws_bedrockagentcore_gateway_rate_limit-data-source

Conversation

@tobydoescode

@tobydoescode tobydoescode commented Aug 12, 2026

Copy link
Copy Markdown

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:

Each data source should be submitted for review in isolation. Pull requests containing multiple data sources and/or resources are harder to review and the maintainers will normally ask for them to be broken apart.

#49429 adds the aws_bedrockagentcore_gateway_rate_limit resource; this PR adds the matching
data 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 Read calls findGatewayRateLimitByTwoPartKey, defined in gateway_rate_limit.go, and its
_basic acceptance test creates a rate limit in order to read one back. I verified this by
rebasing onto main in a scratch worktree — the rebase applies with no conflicts, then fails to
build with undefined: findGatewayRateLimitByTwoPartKey. Decoupling would mean duplicating the
finder 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 six
files 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 the bedrockagentcore service.

Files belonging to this change:

  • internal/service/bedrockagentcore/gateway_rate_limit_data_source.go
  • internal/service/bedrockagentcore/gateway_rate_limit_data_source_test.go
  • internal/service/bedrockagentcore/testdata/GatewayRateLimitDataSource/{basic,not_found}/main.tf
  • website/docs/d/bedrockagentcore_gateway_rate_limit.html.markdown
  • .changelog/49440.txt

Two deliberate divergences from the resource, both noted in the data source documentation so they do not read as oversights:

  • entries is a computed list attribute rather than a nested block. docs/add-a-new-datasource.md requires framework.DataSourceComputedListOfObjectAttribute for objects with only computed attributes, since fully computed blocks are not supported by Terraform protocol V6.
  • status, created_at and updated_at are 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_profile exposes all three on its data source.

Lookup is by rate_limit_id only, mirroring GetGatewayRateLimit. A dimension_keys lookup is also possible in principle, since that tuple is unique per gateway, but it would need a second code path over paginated ListGatewayRateLimits with order-sensitive client-side matching. It can be added later without breaking anyone.

Relations

Relates #49344
Depends on #49429

References

Output from Acceptance Testing

% make testacc PKG=bedrockagentcore TESTS=TestAccBedrockAgentCoreGatewayRateLimitDataSource_

--- PASS: TestAccBedrockAgentCoreGatewayRateLimitDataSource_notFound (19.30s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimitDataSource_basic (30.62s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/bedrockagentcore   39.460s

The resource's nine acceptance tests also still pass on top of this branch:

% make testacc PKG=bedrockagentcore TESTS=TestAccBedrockAgentCoreGatewayRateLimit

--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_duplicateDimensionKeys (28.81s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_multipleLimits (43.77s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimitDataSource_basic (44.88s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_disappears (45.50s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_basic (52.20s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_wildcards (56.28s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_Identity_regionOverride (64.37s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_forceNew (67.96s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_Identity_basic (68.69s)
--- PASS: TestAccBedrockAgentCoreGatewayRateLimit_update (86.28s)

Run in us-west-2 with Terraform v1.15.8.

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
@tobydoescode
tobydoescode requested a review from a team as a code owner August 12, 2026 19:21
@dosubot dosubot Bot added the new-data-source Introduces a new data source. label Aug 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Community Guidelines

This 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

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions Bot added needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. generators Relates to code generators. service/bedrockagentcore Issues and PRs that pertain to the bedrockagentcore service. size/XL Managed by automation to categorize the size of a PR. labels Aug 12, 2026
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-data-source Introduces a new data source. service/bedrockagentcore Issues and PRs that pertain to the bedrockagentcore service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants