AWS CDK Bedrock Alpha Construct Library

raw JSON →
2.252.0a0 verified Fri May 01 auth: no python

Alpha version of the AWS CDK construct library for Amazon Bedrock, enabling generative AI application deployment (foundation models, agents, knowledge bases). Current version 2.252.0a0, updated frequently with CDK releases, pre-GA so breaking changes are common.

pip install aws-cdk-aws-bedrock-alpha
error ModuleNotFoundError: No module named 'aws_cdk.aws_bedrock_alpha'
cause Missing alpha module installation or incorrect import path.
fix
Run pip install aws-cdk-aws-bedrock-alpha and ensure import is from aws_cdk.aws_bedrock_alpha import ...
error AttributeError: module 'aws_cdk.aws_bedrock' has no attribute 'FoundationModel'
cause Importing from the stable aws_bedrock module instead of the alpha module.
fix
Change import to from aws_cdk.aws_bedrock_alpha import FoundationModel
error jsii.errors.JSIIError: Cannot instantiate abstract class 'Agent'
cause Attempting to instantiate Agent without required properties or using outdated CDK version.
fix
Ensure you pass all required constructor props (e.g., foundation_model, instruction) and CDK version ≥ 2.100.0a0.
breaking Alpha module API is unstable — methods and properties may change without notice in new versions. Pin to a specific version in production.
fix Use `aws-cdk-aws-bedrock-alpha==2.252.0a0` in requirements.txt.
deprecated FromFoundationModelId may be deprecated in favor of new model selection patterns in future releases.
fix Check CDK changelog for deprecation notices and migrate to suggested method.
gotcha You must have Bedrock model access enabled in your AWS account for the chosen region. CDK deployment will succeed but runtime calls will fail.
fix Request model access via AWS console or CLI before deploying.

Minimal stack creating a Bedrock agent with a foundation model.

from aws_cdk import App, Stack
from aws_cdk.aws_bedrock_alpha import FoundationModel, Bedrock

app = App()
stack = Stack(app, "BedrockStack")

# Use a foundation model (requires Bedrock access in region)
model = FoundationModel.from_foundation_model_id(
    stack, "Model",
    foundation_model_id="anthropic.claude-v2"
)

# Create a Bedrock agent
agent = Agent(
    stack, "MyAgent",
    foundation_model=model,
    instruction="You are a helpful assistant."
)

app.synth()