Skip to content

r/aws_bedrockagentcore_gateway_target: add connector MCP target configuration#48706

Open
jesseturner21 wants to merge 9 commits into
hashicorp:mainfrom
jesseturner21:agentcore/gateway-target-connector
Open

r/aws_bedrockagentcore_gateway_target: add connector MCP target configuration#48706
jesseturner21 wants to merge 9 commits into
hashicorp:mainfrom
jesseturner21:agentcore/gateway-target-connector

Conversation

@jesseturner21

@jesseturner21 jesseturner21 commented Jun 30, 2026

Copy link
Copy Markdown

Description

Adds the connector MCP target configuration block to aws_bedrockagentcore_gateway_target — a pre-built connector integration target. Supports source.connector_id, enabled, and per-tool configurations with parameter_overrides (path, description, visible) and parameter_values (free-form JSON). Maps to ConnectorTargetConfiguration / ConnectorConfiguration in the AgentCore Control API.

parameter_values is the SDK's document.Interface (free-form JSON), modeled as a jsontypes.Normalized attribute with a smithy-document round-trip (tfsmithy.DocumentFromJSONString / DocumentToJSONString), matching the existing pattern in internal/service/bedrockagent/prompt.go.

Source

  • Go SDK: aws/aws-sdk-go-v2 @ 8881653298eb2d13cc8b60910bd7c2e8b6642df4 (service/bedrockagentcorecontrol, ConnectorTargetConfiguration)

Testing

Two acceptance tests. The connector live-create test is gated on TF_AWS_BEDROCK_KNOWLEDGE_BASE_ID (mirroring the existing Bedrock KB tests' TF_AWS_BEDROCK_OSS_COLLECTION_NAME gating) because the connector requires a MANAGED-type Bedrock knowledge base (see contract below); it was run live against a MANAGED KB:

$ TF_ACC=1 TF_AWS_BEDROCK_KNOWLEDGE_BASE_ID=<managed-kb-id> AWS_REGION=us-east-1 \
  go test -v -timeout 60m ./internal/service/bedrockagentcore/ \
  -run 'TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnector$'
=== RUN   TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnector
=== PAUSE TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnector
=== CONT  TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnector
--- PASS: TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnector (59.09s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrockagentcore	59.237s

The offline plan-only test covers the parameter_values JSON round-trip and parameter_overrides without needing a KB:

$ TF_ACC=1 go test -v -timeout 60m ./internal/service/bedrockagentcore/ \
  -run 'TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnectorParameters'
=== RUN   TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnectorParameters
=== PAUSE TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnectorParameters
=== CONT  TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnectorParameters
--- PASS: TestAccBedrockAgentCoreGatewayTarget_targetConfigurationConnectorParameters (9.76s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrockagentcore	9.924s

Connector contract (verified against the live API)

Pinned down by probing CreateGatewayTarget directly:

  • Valid configurations[].name → only Retrieve (RetrieveAndGenerate / retrieve"Configuration 'X': not found in connector").
  • Valid parameter_values key → only knowledgeBaseId (numberOfResults"'numberOfResults' is not a recognized parameter").
  • The KB must be MANAGED-type — a VECTOR KB fails with "Retrieve is not supported for this knowledge base type."
  • The gateway execution role needs bedrock:Retrieve and bedrock:GetKnowledgeBase on the KB ARN (the connector validation calls GetKnowledgeBase to inspect the KB type; Retrieve alone → "Insufficient permissions to validate the specified resource").
  • A time_sleep guards the newly-created inline policy's propagation before the target is validated.

The test config provisions the gateway, grants the role those two actions, creates the connector target against the KB, and import-verifies it.

Closes #48503

@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. service/bedrockagentcore Issues and PRs that pertain to the bedrockagentcore service. size/XL Managed by automation to categorize the size of a PR. labels Jun 30, 2026
@jesseturner21 jesseturner21 marked this pull request as ready for review July 1, 2026 22:55
@jesseturner21 jesseturner21 requested a review from a team as a code owner July 1, 2026 22:55
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 2, 2026
…e credential provider at plan time

- The mcp target union (api_gateway, connector, lambda, mcp_server, open_api_schema,
  smithy_model) had only SizeAtMost(1) per member and no cross-field rule, so setting
  two members passed validation and apply "succeeded" while Expand kept only the first
  (switch order), leaving a perpetual "+ <dropped member>" diff. Added
  listvalidator.ExactlyOneOf across the six members.
- credential_provider_configuration members used ConflictsWith (preventing multiples)
  but nothing required at least one, so an empty credential_provider_configuration {}
  passed validation and only failed at apply ("At least one credential provider must
  be configured"). Added listvalidator.AtLeastOneOf across the five members; combined
  with the existing ConflictsWith this yields exactly-one semantics.

Add an acctest asserting multiple mcp members, no mcp member, and an empty
credential_provider_configuration are all rejected at plan time.
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. enhancement Requests to existing resources that expand the functionality or scope. 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.

aws_bedrockagentcore_gateway_target: Add support for connector target configuration

3 participants