AWS CDK Cloud Assembly Schema
The `aws-cdk-cloud-assembly-schema` Python library defines the schema for the Cloud Assembly, which is the output of the AWS CDK's synthesis operation (e.g., `cdk synth`). This schema, primarily found in `manifest.json`, acts as the communication protocol between the AWS CDK framework (libraries) and the AWS CDK CLI (tools), providing instructions for deploying infrastructure. The library is actively maintained with frequent updates, usually in sync with the broader AWS CDK CLI project, currently at version 53.14.0.
Warnings
- breaking Cloud Assembly Schema Version Mismatch: A common breaking error occurs when the AWS CDK CLI version is incompatible with the `aws-cdk-lib` version used by your application, leading to a 'Cloud assembly schema version mismatch' error. This happens because the schema version is strictly tied to the CDK libraries.
- gotcha Intended Use as Internal Protocol: This library primarily defines the internal communication protocol (the Cloud Assembly manifest) between the AWS CDK framework and the AWS CDK CLI. It is generally not intended for direct use by end-developers building AWS CDK applications to define infrastructure, unlike `aws-cdk-lib`.
- gotcha Strict Major Versioning Policy: The `aws-cdk-cloud-assembly-schema` follows semantic versioning with a critical nuance: *any* change to the schema, even if it doesn't strictly break JSON schema validation, results in a major version bump. This is because every instruction in the manifest is crucial for correct deployment behavior.
Install
-
pip install aws-cdk-cloud-assembly-schema
Imports
- AssetManifest
from aws_cdk.cloud_assembly_schema import AssetManifest
Quickstart
import os
import aws_cdk as cdk
import aws_cdk.aws_s3 as s3
from constructs import Construct
class MyCdkStack(cdk.Stack):
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# Create an S3 bucket
s3.Bucket(self, "MyBucket",
versioned=True,
removal_policy=cdk.RemovalPolicy.DESTROY,
auto_delete_objects=True
)
app = cdk.App()
MyCdkStack(app, "MyFirstCdkStack",
env=cdk.Environment(
account=os.environ.get("CDK_DEFAULT_ACCOUNT", ""),
region=os.environ.get("CDK_DEFAULT_REGION", "eu-west-1")
)
)
app.synth()