cdk-common

raw JSON →
2.1.27 verified Mon Apr 27 auth: no python

Common AWS CDK library providing reusable constructs and utilities for AWS CDK applications. Version 2.1.27, supporting Python ~=3.9. Active development with weekly releases.

pip install cdk-common
error ModuleNotFoundError: No module named 'cdk_common'
cause The package 'cdk-common' installs with hyphens but the Python import uses underscores.
fix
Run 'pip install cdk-common' and import using 'import cdk_common'.
error AttributeError: module 'cdk_common' has no attribute 'BaseConstruct'
cause The symbol is not exported from the package's __init__.py; it may be in a submodule.
fix
Update to latest version (2.1.27) and use 'from cdk_common import BaseConstruct'.
error jsii.errors.JSIIError: There is already a resource with name 'MyConstruct' in scope 'MyStack'
cause Duplicate construct ID within the same scope.
fix
Use unique IDs for each construct, e.g., by appending a suffix.
breaking Version 2.x migrated from aws-cdk-lib v1 to v2. All imports must use aws_cdk (v2) not @aws-cdk/*.
fix Replace all @aws-cdk/* imports with aws_cdk.* equivalents.
deprecated The function 'create_lambda_function' was replaced by 'LambdaFunction' class in v1.5.0.
fix Use 'from cdk_common import LambdaFunction' instead.
gotcha Construct IDs must be unique within the same scope; reusing IDs causes synthesis failure.
fix Always use unique construct IDs, e.g., via 'self.id' or a counter.
gotcha Not all constructs accept 'kwargs' for all properties; check the specific construct's signature.
fix Refer to the official documentation for the required parameters of each construct.

Minimal CDK app using cdk-common's BaseConstruct.

from aws_cdk import App, Stack
from cdk_common import BaseConstruct

class MyStack(Stack):
    def __init__(self, scope, id, **kwargs):
        super().__init__(scope, id, **kwargs)
        BaseConstruct(self, "MyConstruct")

app = App()
MyStack(app, "MyStack")
app.synth()