{"id":20975,"library":"aws-cdk-aws-batch","title":"AWS CDK AWS Batch Construct Library","description":"The CDK Construct Library for AWS::Batch, enabling you to define and deploy AWS Batch resources (compute environments, job queues, job definitions) as infrastructure as code. Version 1.204.0 is a v1 release (maintenance mode) with monthly cadence. The stable v2 counterpart is 'aws-cdk-lib/aws-batch'.","status":"maintenance","version":"1.204.0","language":"python","source_language":"en","source_url":"https://github.com/aws/aws-cdk/tree/main/packages/%40aws-cdk/aws-batch","tags":["AWS","CDK","Batch","infrastructure","cloud"],"install":[{"cmd":"pip install aws-cdk-aws-batch","lang":"bash","label":"Install v1 construct library"}],"dependencies":[{"reason":"Core CDK library, version must be >=1.204.0, <2.0","package":"aws-cdk-lib","optional":false}],"imports":[{"note":"The pip package is 'aws-cdk-aws-batch' but the import namespace is 'aws_cdk.aws_batch' (underscored).","wrong":"from aws_cdk_aws_batch import ...","symbol":"Batch","correct":"from aws_cdk.aws_batch import CfnComputeEnvironment, CfnJobQueue, CfnJobDefinition"},{"note":"In v1, only L1 CloudFormation resources (Cfn*) are available. L2 constructs (e.g., ComputeEnvironment) exist in v2.","wrong":"from aws_cdk.aws_batch import ComputeEnvironment","symbol":"ComputeEnvironment","correct":"from aws_cdk.aws_batch import CfnComputeEnvironment"}],"quickstart":{"code":"import aws_cdk as cdk\nfrom aws_cdk.aws_batch import CfnComputeEnvironment, CfnJobQueue, CfnJobDefinition\n\napp = cdk.App()\nstack = cdk.Stack(app, 'MyBatchStack')\n\ncompute_env = CfnComputeEnvironment(stack, 'MyComputeEnv',\n    type='MANAGED',\n    service_role='arn:aws:iam::123456789012:role/AWSBatchServiceRole',\n    compute_resources=CfnComputeEnvironment.ComputeResourcesProperty(\n        type='EC2',\n        minv_cpus=0,\n        maxv_cpus=256,\n        desiredv_cpus=0,\n        instance_types=['c5.large'],\n        subnets=['subnet-12345678'],\n        security_group_ids=['sg-12345678']\n    )\n)\n\njob_queue = CfnJobQueue(stack, 'MyJobQueue',\n    job_queue_name='MyQueue',\n    compute_environment_order=[\n        CfnJobQueue.ComputeEnvironmentOrderProperty(\n            compute_environment=compute_env.ref,\n            order=1\n        )\n    ]\n)\n\napp.synth()","lang":"python","description":"Create a simple AWS Batch compute environment and job queue using L1 CloudFormation resources."},"warnings":[{"fix":"Use 'aws-cdk-lib/aws-batch' with CDK v2.","message":"aws-cdk-aws-batch v1 is in maintenance mode. No new features, only critical bug fixes. Migrate to v2 for full support.","severity":"deprecated","affected_versions":">=1.0.0, <2.0.0"},{"fix":"Use Cfn* constructs or migrate to CDK v2 for L2 constructs.","message":"In v1, only L1 CloudFormation resources (Cfn*) exist. L2 constructs like aws_batch.ComputeEnvironment were introduced in v2.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Import from 'aws_cdk.aws_batch', not 'aws_cdk_aws_batch'.","message":"The pip package name is 'aws-cdk-aws-batch', but the import path is 'aws_cdk.aws_batch' (hyphens become underscores).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from aws_cdk.aws_batch import ...'","cause":"Incorrect import path; the package name uses hyphens, but the import uses underscores.","error":"ModuleNotFoundError: No module named 'aws_cdk_aws_batch'"},{"fix":"Use CfnComputeEnvironment instead, or upgrade to CDK v2.","cause":"Trying to use L2 construct in v1; only Cfn* resources exist.","error":"'module' object has no attribute 'ComputeEnvironment'"},{"fix":"Check the CloudFormation resource specification and use the correct Property objects.","cause":"Misuse of Cfn* property structure; e.g., passing a list where a single value is expected.","error":"AttributeError: 'list' object has no attribute 'to_string'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}