{"id":8849,"library":"aws-cdk-assets","title":"AWS CDK Assets (Deprecated)","description":"The `aws-cdk-assets` module (v1.x) for the AWS Cloud Development Kit (CDK) is deprecated. Its functionality, primarily for S3 and ECR assets, has been consolidated into specific, dedicated asset modules such as `aws-cdk.aws_s3_assets` and `aws-cdk.aws_ecr_assets` within CDK v1, or `aws_cdk_lib.aws_s3_assets` and `aws_cdk_lib.aws_ecr_assets` for CDK v2. It currently publishes alongside `aws-cdk` v1 releases, but its direct use is strongly discouraged.","status":"deprecated","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws-cdk","aws","cloud","assets","s3","ecr","deprecated"],"install":[{"cmd":"pip install aws-cdk-assets","lang":"bash","label":"Deprecated Installation"},{"cmd":"pip install aws-cdk-lib","lang":"bash","label":"Recommended for CDK v2+"},{"cmd":"pip install aws-cdk.core aws-cdk.aws-s3-assets","lang":"bash","label":"Recommended for CDK v1 (specific asset types)"}],"dependencies":[],"imports":[{"note":"The `aws-cdk-assets` package is deprecated. For CDK v1, use specific modules like `aws_cdk.aws_s3_assets` or `aws_cdk.aws_ecr_assets`. For CDK v2+, use `aws_cdk_lib.aws_s3_assets` or `aws_cdk_lib.aws_ecr_assets`.","wrong":"from aws_cdk.aws_cdk_assets import Asset","symbol":"Asset","correct":"from aws_cdk_lib import aws_s3_assets"},{"note":"Docker assets are now found in dedicated modules (e.g., `aws_cdk_lib.aws_ecr_assets`).","wrong":"from aws_cdk.aws_cdk_assets import DockerImageAsset","symbol":"DockerImageAsset","correct":"from aws_cdk_lib import aws_ecr_assets"}],"quickstart":{"code":"import os\nfrom aws_cdk import (  # aws-cdk-lib for v2\n    App, Stack,\n    aws_s3_assets as s3_assets,\n    aws_s3 as s3\n)\n\nclass MyAssetStack(Stack):\n    def __init__(self, scope: App, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        # Create a dummy directory for the asset\n        asset_dir = 'my-asset-content'\n        os.makedirs(asset_dir, exist_ok=True)\n        with open(os.path.join(asset_dir, 'hello.txt'), 'w') as f:\n            f.write('Hello, CDK Assets!')\n\n        # Define an S3 Asset (CDK v2 example)\n        my_asset = s3_assets.Asset(self, 'MyFileAsset',\n            path=asset_dir\n        )\n\n        # Create an S3 Bucket and grant read access to the asset\n        bucket = s3.Bucket(self, 'MyBucket',\n            versioned=True  # Assets can be versioned\n        )\n\n        # Output the asset S3 path\n        self.asset_s3_url = my_asset.s3_object_url\n        print(f\"Asset S3 URL: {self.asset_s3_url}\")\n\n        # Clean up dummy directory (optional)\n        # import shutil\n        # shutil.rmtree(asset_dir)\n\nif __name__ == '__main__':\n    app = App()\n    stack = MyAssetStack(app, 'MyAssetStackExample')\n    # Uncomment to synthesize for deployment\n    # app.synth()\n","lang":"python","description":"This quickstart demonstrates how to use the recommended pattern for S3 assets within AWS CDK (v2+). Instead of `aws-cdk-assets`, you directly import and use `aws_s3_assets` from the `aws-cdk-lib` package. For CDK v1, replace `aws_cdk_lib` with `aws_cdk` and ensure you `pip install aws-cdk.aws-s3-assets`."},"warnings":[{"fix":"Migrate to dedicated asset modules: `aws_cdk.aws_s3_assets` / `aws_cdk.aws_ecr_assets` for CDK v1, or `aws_cdk_lib.aws_s3_assets` / `aws_cdk_lib.aws_ecr_assets` for CDK v2.","message":"The `aws-cdk-assets` package is deprecated and should not be used. Its constructs are no longer maintained or actively developed under this specific package name.","severity":"breaking","affected_versions":"All versions (especially from CDK v1.x onwards and completely in v2+)"},{"fix":"Update your imports to use `from aws_cdk_lib import aws_s3_assets` (CDK v2) or `from aws_cdk import aws_s3_assets` (CDK v1) and ensure `aws-cdk-lib` or `aws-cdk.aws-s3-assets` is installed.","message":"Attempting to use `from aws_cdk.aws_cdk_assets import Asset` or similar imports will result in `ModuleNotFoundError` or `AttributeError` when using `aws-cdk-lib` (CDK v2) or recent versions of `aws-cdk.core` (CDK v1).","severity":"gotcha","affected_versions":"CDK v1.x (newer releases) and all CDK v2.x"},{"fix":"Refactor your CDK code to use the modern asset handling patterns provided directly by `aws-cdk-lib` (v2) or specific `aws-cdk.<service-name>-assets` modules (v1).","message":"Even though `aws-cdk-assets` might still be installable for legacy reasons, its API is no longer part of the standard `aws-cdk` or `aws-cdk-lib` structure, leading to compatibility issues.","severity":"deprecated","affected_versions":"All versions of `aws-cdk-assets`"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install `aws-cdk-lib` (for v2) or `aws-cdk.aws-s3-assets` (for v1) and update imports: `from aws_cdk_lib import aws_s3_assets` or `from aws_cdk import aws_s3_assets`.","cause":"The `aws_cdk.aws_cdk_assets` module is deprecated and no longer part of the standard `aws-cdk` (v1) or `aws-cdk-lib` (v2) distributions.","error":"ModuleNotFoundError: No module named 'aws_cdk.aws_cdk_assets'"},{"fix":"Import `Asset` (or `DockerImageAsset`) from the specific assets module: `from aws_cdk_lib import aws_s3_assets` then use `s3_assets.Asset(...)`.","cause":"You are trying to import `Asset` from a general service module (`aws_s3`) instead of the dedicated assets module.","error":"AttributeError: module 'aws_cdk_lib.aws_s3' has no attribute 'Asset'"},{"fix":"Ensure the `path` argument to `s3_assets.Asset` points to an existing directory or file. Use `os.path.join(os.getcwd(), 'your_dir')` for absolute paths if needed.","cause":"The asset path specified in the `Asset` construct does not exist relative to your `cdk.json` or the working directory where `cdk synth` is executed.","error":"jsii.errors.JavaScriptError: In 'new @aws-cdk/assets.Asset()': Path '<path>' does not exist."}]}