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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 86.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 11.0s · import 0.000s · 87MB
92MB installed
● package 92MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Batch
✓ from aws_cdk.aws_batch import CfnComputeEnvironment, CfnJobQueue, CfnJobDefinition
✗ from aws_cdk_aws_batch import ...
The pip package is 'aws-cdk-aws-batch' but the import namespace is 'aws_cdk.aws_batch' (underscored).
ComputeEnvironment
✓ from aws_cdk.aws_batch import CfnComputeEnvironment
✗ from aws_cdk.aws_batch import ComputeEnvironment
In v1, only L1 CloudFormation resources (Cfn*) are available. L2 constructs (e.g., ComputeEnvironment) exist in v2.
Create a simple AWS Batch compute environment and job queue using L1 CloudFormation resources.
import aws_cdk as cdk
from aws_cdk.aws_batch import CfnComputeEnvironment, CfnJobQueue, CfnJobDefinition
app = cdk.App()
stack = cdk.Stack(app, 'MyBatchStack')
compute_env = CfnComputeEnvironment(stack, 'MyComputeEnv',
type='MANAGED',
service_role='arn:aws:iam::123456789012:role/AWSBatchServiceRole',
compute_resources=CfnComputeEnvironment.ComputeResourcesProperty(
type='EC2',
minv_cpus=0,
maxv_cpus=256,
desiredv_cpus=0,
instance_types=['c5.large'],
subnets=['subnet-12345678'],
security_group_ids=['sg-12345678']
)
)
job_queue = CfnJobQueue(stack, 'MyJobQueue',
job_queue_name='MyQueue',
compute_environment_order=[
CfnJobQueue.ComputeEnvironmentOrderProperty(
compute_environment=compute_env.ref,
order=1
)
]
)
app.synth()
cdk --version
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_cdk_aws_batch'
Incorrect import path; the package name uses hyphens, but the import uses underscores.
fixUse 'from aws_cdk.aws_batch import ...'
'module' object has no attribute 'ComputeEnvironment'
Trying to use L2 construct in v1; only Cfn* resources exist.
fixUse CfnComputeEnvironment instead, or upgrade to CDK v2.
AttributeError: 'list' object has no attribute 'to_string'
Misuse of Cfn* property structure; e.g., passing a list where a single value is expected.
fixCheck the CloudFormation resource specification and use the correct Property objects.
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
aws-cdk-librequiredCore CDK library, version must be >=1.204.0, <2.0