{"id":20976,"library":"aws-cdk-aws-sam","title":"AWS CDK SAM Construct Library","description":"The CDK Construct Library for the AWS Serverless Application Model (SAM) resources. Version 1.204.0 is the latest release for CDK v1 (maintenance mode). This library is part of the AWS CDK v1 which entered maintenance on June 1, 2022 and will end support on June 1, 2025. Users are strongly encouraged to migrate to CDK v2 where SAM constructs are available via the 'aws-cdk-lib/aws-sam' module.","status":"maintenance","version":"1.204.0","language":"python","source_language":"en","source_url":"https://github.com/aws/aws-cdk","tags":["aws","cdk","sam","serverless","infrastructure-as-code"],"install":[{"cmd":"pip install aws-cdk-aws-sam==1.204.0","lang":"bash","label":"Install specific version"},{"cmd":"pip install aws-cdk-aws-sam","lang":"bash","label":"Install latest v1 (deprecated)"}],"dependencies":[{"reason":"CDK v1 runtime required; SAM constructs depend on core CDK library","package":"aws-cdk-lib","optional":false},{"reason":"Foundation for CDK constructs","package":"constructs","optional":false}],"imports":[{"note":"Correct import for CDK v1 SAM resources","symbol":"CfnServerlessFunction","correct":"from aws_cdk.aws_sam import CfnServerlessFunction"},{"note":"Correct import for CDK v1 SAM resources","symbol":"CfnServerlessApi","correct":"from aws_cdk.aws_sam import CfnServerlessApi"}],"quickstart":{"code":"from aws_cdk import core\nfrom aws_cdk.aws_sam import CfnServerlessFunction\n\napp = core.App()\nstack = core.Stack(app, \"MySamStack\")\n\nCfnServerlessFunction(stack, \"MyFunction\",\n    code_uri=\"./\",\n    handler=\"index.handler\",\n    runtime=\"python3.9\",\n    events={\n        \"MyApi\": {\n            \"Type\": \"Api\",\n            \"Properties\": {\n                \"Path\": \"/hello\",\n                \"Method\": \"GET\"\n            }\n        }\n    }\n)\n\napp.synth()","lang":"python","description":"Basic CDK v1 SAM application with a Lambda function triggered by an API Gateway event."},"warnings":[{"fix":"Migrate to CDK v2: replace 'aws-cdk-aws-sam' with 'aws-cdk-lib/aws-sam'.","message":"CDK v1 is in maintenance mode and will reach end-of-life on June 1, 2025. All active development has shifted to CDK v2.","severity":"deprecated","affected_versions":"all"},{"fix":"Use 'from aws_cdk.aws_sam import ...' via 'aws-cdk-lib' (v2) or install 'aws-cdk-lib' directly.","message":"In CDK v2, SAM constructs are no longer in a separate package. Import paths and class names may differ. The package 'aws-cdk-aws-sam' does not exist for CDK v2.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use a virtual environment and install only one CDK version.","message":"The SAM package is only compatible with CDK v1. If you install both v1 and v2 packages in the same environment, you may encounter import conflicts.","severity":"gotcha","affected_versions":"all"},{"fix":"Evaluate migration to CDK v2 for ongoing support.","message":"The 'aws-cdk-aws-sam' package will not receive new features; only critical bug fixes.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install aws-cdk-aws-sam (v1) or use 'from aws_cdk.aws_sam import ...' from 'aws-cdk-lib' (v2).","cause":"Installed CDK v2 but tried to import SAM from the v1 package path.","error":"ModuleNotFoundError: No module named 'aws_cdk.aws_sam'"},{"fix":"Ensure aws-cdk-aws-sam is installed and check that the class name exists in the installed version.","cause":"The SAM construct names may differ between CDK versions or the package is not installed.","error":"ImportError: cannot import name 'CfnServerlessFunction' from 'aws_cdk.aws_sam'"},{"fix":"Use 'from aws_cdk.aws_sam import ...' explicitly.","cause":"Trying to access aws_sam as a submodule directly (e.g., import aws_cdk; aws_cdk.aws_sam) without importing it first.","error":"'module' object has no attribute 'aws_sam'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}