Skip to content

fix(bedrock-agentcore-alpha): relax allowlistedHeaders pattern to match CFN schema#37969

Open
naviret wants to merge 2 commits into
aws:mainfrom
naviret:fix/bedrock-agentcore-runtime-header-pattern
Open

fix(bedrock-agentcore-alpha): relax allowlistedHeaders pattern to match CFN schema#37969
naviret wants to merge 2 commits into
aws:mainfrom
naviret:fix/bedrock-agentcore-runtime-header-pattern

Conversation

@naviret
Copy link
Copy Markdown

@naviret naviret commented May 21, 2026

Issue # (if applicable)

Closes #37964.

Reason for this change

The validateRequestHeaderConfiguration method in @aws-cdk/aws-bedrock-agentcore-alpha uses an outdated regex that only allows Authorization and X-Amzn-Bedrock-AgentCore-Runtime-Custom-* headers. The CloudFormation schema for AWS::BedrockAgentCore::Runtime has been updated and deployed to all regions to accept ^[A-Za-z][A-Za-z0-9_-]{0,255}$ (any valid HTTP header name).

This causes cdk synth to throw InvalidRequestHeaderConfiguration for valid headers that the service fully supports. Customers must use a CFN escape hatch to work around this.

Description of changes

  • Updated the regex in validateRequestHeaderConfiguration from /(Authorization|X-Amzn-Bedrock-AgentCore-Runtime-Custom-[a-zA-Z0-9-]+)/ to /^[A-Za-z][A-Za-z0-9_-]{0,255}$/ to match the deployed CFN schema
  • Policy enforcement (blocking restricted headers) is handled server-side in the control plane — the CDK construct only needs format validation

Describe any new or updated permissions being added

N/A — no IAM permission changes.

Description of how you validated changes

  • Added unit tests for request header configuration validation:
    • Headers beyond the old X-Amzn-Bedrock-AgentCore-Runtime-Custom- prefix (should pass)
    • Headers with invalid characters like spaces (should fail)
    • Headers starting with a number (should fail)
    • Empty headers (should fail)
    • Headers with underscores (should pass)
  • Added integration test with snapshot
  • Local build and lint pass

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions Bot added the p2 label May 21, 2026
@github-actions github-actions Bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label May 21, 2026
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@github-actions github-actions Bot added the feature-request A feature should be added or improved. label May 22, 2026
…ch CFN schema

The `validateRequestHeaderConfiguration` method rejected valid headers
that the service and CloudFormation schema already accept. Update the
regex from the old restrictive pattern (only `Authorization` and
`X-Amzn-Bedrock-AgentCore-Runtime-Custom-*`) to `^[A-Za-z][A-Za-z0-9_-]{0,255}$`,
matching the deployed CFN schema for `AWS::BedrockAgentCore::Runtime`.

Policy enforcement (restricted headers, internal-only headers) is handled
server-side in the control plane service layer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@naviret naviret force-pushed the fix/bedrock-agentcore-runtime-header-pattern branch from d67e342 to ab66d46 Compare May 22, 2026 19:17
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 22, 2026 19:31

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

…owlist

Adds integration test that creates a Runtime with headers beyond the
X-Amzn-Bedrock-AgentCore-Runtime-Custom- prefix (e.g. X-Twilio-Signature,
X-Api-Key) to verify the relaxed pattern produces valid CFN templates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@naviret naviret force-pushed the fix/bedrock-agentcore-runtime-header-pattern branch from 0054f68 to 590177d Compare May 22, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@aws-cdk/aws-bedrock-agentcore-alpha: Runtime allowlistedHeaders validation rejects valid headers supported by the AgentCore

2 participants