Install & Compatibility
Where this runs
tested against v1.204.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.960 runs
installs and imports cleanly · install 0.0s · import 0.000s · 479.7MB
glibcpy 3.10–3.960 runs
installs and imports cleanly · install 8.4s · import 0.000s · 551MB
555MB installed
● package 555MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Asset
✓ from aws_cdk.aws_s3_assets import Asset
✗ from aws_cdk.aws_s3_assets import Asset
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`.
import os
from aws_cdk import ( # aws-cdk-lib for v2
App, Stack,
aws_s3_assets as s3_assets,
aws_s3 as s3
)
class MyAssetStack(Stack):
def __init__(self, scope: App, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
# Create a dummy directory for the asset
asset_dir = 'my-asset-content'
os.makedirs(asset_dir, exist_ok=True)
with open(os.path.join(asset_dir, 'hello.txt'), 'w') as f:
f.write('Hello, CDK Assets!')
# Define an S3 Asset (CDK v2 example)
my_asset = s3_assets.Asset(self, 'MyFileAsset',
path=asset_dir
)
# Create an S3 Bucket and grant read access to the asset
bucket = s3.Bucket(self, 'MyBucket',
versioned=True # Assets can be versioned
)
# Output the asset S3 path
self.asset_s3_url = my_asset.s3_object_url
print(f"Asset S3 URL: {self.asset_s3_url}")
# Clean up dummy directory (optional)
# import shutil
# shutil.rmtree(asset_dir)
if __name__ == '__main__':
app = App()
stack = MyAssetStack(app, 'MyAssetStackExample')
# Uncomment to synthesize for deployment
# app.synth()
Debug
Known issues
breakingThe `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.fixMigrate 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.
affects: All versions (especially from CDK v1.x onwards and completely in v2+)
gotchaAttempting 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).fixUpdate 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.
affects: CDK v1.x (newer releases) and all CDK v2.x
deprecatedEven 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.fixRefactor 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).
affects: All versions of `aws-cdk-assets`
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
No dependency data recorded yet.