AWS CDK Batch (Alpha)
raw JSON → 2.95.1a0 verified Sat May 09 auth: no python
The CDK Construct Library for AWS::Batch (Alpha). Current version: 2.95.1a0. This is an alpha module with no SLA or feature freeze; APIs are subject to breaking changes without major version bumps.
pip install aws-cdk-aws-batch-alpha Common errors
error ModuleNotFoundError: No module named 'aws_cdk.aws_batch' ↓
cause Trying to import from the non-alpha module without installing alpha package.
fix
Install aws-cdk-aws-batch-alpha and import from aws_cdk.aws_batch_alpha.
error AttributeError: 'module' object has no attribute 'JobDefinition' ↓
cause Trying to import JobDefinition from the wrong module (awscdk.aws_batch) or missing alpha suffix.
fix
Ensure you have from aws_cdk.aws_batch_alpha import JobDefinition.
error TypeError: argument of type 'NoneType' is not iterable ↓
cause Passing None for required arguments like 'vpc' or 'compute_environments'.
fix
Always provide a valid Vpc object and a list of compute environments to JobQueue.
error jsii.errors.JSIIError: Resource of type 'AWS::Batch::JobDefinition' has no property 'containerProperties' ↓
cause Using outdated container property names that changed in newer versions of the alpha module.
fix
Refer to the latest CDK documentation for the correct container properties (e.g., use 'container' instead of 'containerProperties').
Warnings
breaking Alpha modules have no stability guarantee; minor version bumps can include breaking changes without warning. Pin to exact version in production. ↓
fix Pin version: pip install aws-cdk-aws-batch-alpha==2.95.1a0
gotcha Import paths require '_alpha' suffix; common mistake to import from aws_cdk.aws_batch instead of aws_cdk.aws_batch_alpha. ↓
fix Use correct import: from aws_cdk.aws_batch_alpha import ...
deprecated Some properties (e.g., 'environment' in JobDefinition) have been deprecated in favor of new constructs. Check CDK documentation for current patterns. ↓
fix Use the latest construct properties as per CDK API reference.
Imports
- Batch wrong
from aws_cdk.aws_batch import Batchcorrectfrom aws_cdk.aws_batch_alpha import Batch - JobDefinition wrong
from aws_cdk.aws_batch import JobDefinitioncorrectfrom aws_cdk.aws_batch_alpha import JobDefinition - ComputeEnvironment
from aws_cdk.aws_batch_alpha import ComputeEnvironment - JobQueue
from aws_cdk.aws_batch_alpha import JobQueue
Quickstart
from aws_cdk import App, Stack
from aws_cdk.aws_batch_alpha import Batch, ComputeEnvironment, JobDefinition, JobQueue
from aws_cdk.aws_ec2 import Vpc
from constructs import Construct
app = App()
stack = Stack(app, "MyBatchStack")
vpc = Vpc(stack, "Vpc")
compute_env = ComputeEnvironment(
stack, "ComputeEnv",
managed=True,
vpc=vpc
)
job_queue = JobQueue(
stack, "JobQueue",
priority=1,
compute_environments=[compute_env]
)
job_def = JobDefinition(
stack, "JobDef",
container={
"image": "public.ecr.aws/batch/job:latest",
"command": ["echo", "hello"],
"memory": 512,
"vcpus": 1
}
)
app.synth()