CfnComputeEnvironmentPropsMixin
- class aws_cdk.mixins_preview.aws_batch.mixins.CfnComputeEnvironmentPropsMixin(props, *, strategy=None)
Bases:
MixinThe
AWS::Batch::ComputeEnvironmentresource defines your AWS Batch compute environment.You can define
MANAGEDorUNMANAGEDcompute environments.MANAGEDcompute environments can use Amazon EC2 or AWS Fargate resources.UNMANAGEDcompute environments can only use EC2 resources. For more information, see Compute Environments in the ** .In a managed compute environment, AWS Batch manages the capacity and instance types of the compute resources within the environment. This is based on the compute resource specification that you define or the launch template that you specify when you create the compute environment. You can choose either to use EC2 On-Demand Instances and EC2 Spot Instances, or to use Fargate and Fargate Spot capacity in your managed compute environment. You can optionally set a maximum price so that Spot Instances only launch when the Spot Instance price is below a specified percentage of the On-Demand price. .. epigraph:
Multi-node parallel jobs are not supported on Spot Instances.
In an unmanaged compute environment, you can manage your own EC2 compute resources and have a lot of flexibility with how you configure your compute resources. For example, you can use custom AMI. However, you need to verify that your AMI meets the Amazon ECS container instance AMI specification. For more information, see container instance AMIs in the Amazon Elastic Container Service Developer Guide . After you have created your unmanaged compute environment, you can use the DescribeComputeEnvironments operation to find the Amazon ECS cluster that is associated with it. Then, manually launch your container instances into that Amazon ECS cluster. For more information, see Launching an Amazon ECS container instance in the Amazon Elastic Container Service Developer Guide . .. epigraph:
To create a compute environment that uses EKS resources, the caller must have permissions to call ``eks:DescribeCluster`` . > AWS Batch doesn't upgrade the AMIs in a compute environment after it's created except under specific conditions. For example, it doesn't automatically update the AMIs when a newer version of the Amazon ECS optimized AMI is available. Therefore, you're responsible for the management of the guest operating system (including updates and security patches) and any additional application software or utilities that you install on the compute resources. There are two ways to use a new AMI for your AWS Batch jobs. The original method is to complete these steps: - Create a new compute environment with the new AMI. - Add the compute environment to an existing job queue. - Remove the earlier compute environment from your job queue. - Delete the earlier compute environment. In April 2022, AWS Batch added enhanced support for updating compute environments. For example, the ``UpdateComputeEnvironent`` API lets you use the ``ReplaceComputeEnvironment`` property to dynamically update compute environment parameters such as the launch template or instance type without replacement. For more information, see `Updating compute environments <https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html>`_ in the *AWS Batch User Guide* . To use the enhanced updating of compute environments to update AMIs, follow these rules: - Either do not set the `ServiceRole <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-batch-computeenvironment.html#cfn-batch-computeenvironment-servicerole>`_ property or set it to the *AWSServiceRoleForBatch* service-linked role. - Set the `AllocationStrategy <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-allocationstrategy>`_ property to ``BEST_FIT_PROGRESSIVE`` or ``SPOT_CAPACITY_OPTIMIZED`` . - Set the `ReplaceComputeEnvironment <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-batch-computeenvironment.html#cfn-batch-computeenvironment-replacecomputeenvironment>`_ property to ``false`` . .. epigraph:: Set the ``ReplaceComputeEnvironment`` property to ``true`` if the compute environment uses the ``BEST_FIT`` allocation strategy. > If the ``ReplaceComputeEnvironment`` property is set to ``false`` , you might receive an error message when you update the CFN template for a compute environment. This issue occurs if the updated ``desiredvcpus`` value is less than the current ``desiredvcpus`` value. As a workaround, delete the ``desiredvcpus`` value from the updated template or use the ``minvcpus`` property to manage the number of vCPUs. For information, see `Error message when you update the ``DesiredvCpus`` setting <https://docs.aws.amazon.com/batch/latest/userguide/troubleshooting.html#error-desired-vcpus-update>`_ . - Set the `UpdateToLatestImageVersion <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-updatetolatestimageversion>`_ property to ``true`` . This property is used when you update a compute environment. The `UpdateToLatestImageVersion <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-updatetolatestimageversion>`_ property is ignored when you create a compute environment. - Either do not specify an image ID in `ImageId <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-imageid>`_ or `ImageIdOverride <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-ec2configurationobject.html#cfn-batch-computeenvironment-ec2configurationobject-imageidoverride>`_ properties, or in the launch template identified by the `Launch Template <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-launchtemplate>`_ property. In that case AWS Batch will select the latest Amazon ECS optimized AMI supported by AWS Batch at the time the infrastructure update is initiated. Alternatively you can specify the AMI ID in the ``ImageId`` or ``ImageIdOverride`` properties, or the launch template identified by the ``LaunchTemplate`` properties. Changing any of these properties will trigger an infrastructure update. If these rules are followed, any update that triggers an infrastructure update will cause the AMI ID to be re-selected. If the `Version <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html#cfn-batch-computeenvironment-launchtemplatespecification-version>`_ property of the `LaunchTemplateSpecification <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html>`_ is set to ``$Latest`` or ``$Default`` , the latest or default version of the launch template will be evaluated up at the time of the infrastructure update, even if the ``LaunchTemplateSpecification`` was not updated.
- See:
- CloudformationResource:
AWS::Batch::ComputeEnvironment
- Mixin:
true
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview import mixins from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins cfn_compute_environment_props_mixin = batch_mixins.CfnComputeEnvironmentPropsMixin(batch_mixins.CfnComputeEnvironmentMixinProps( compute_environment_name="computeEnvironmentName", compute_resources=batch_mixins.CfnComputeEnvironmentPropsMixin.ComputeResourcesProperty( allocation_strategy="allocationStrategy", bid_percentage=123, desiredv_cpus=123, ec2_configuration=[batch_mixins.CfnComputeEnvironmentPropsMixin.Ec2ConfigurationObjectProperty( image_id_override="imageIdOverride", image_kubernetes_version="imageKubernetesVersion", image_type="imageType" )], ec2_key_pair="ec2KeyPair", image_id="imageId", instance_role="instanceRole", instance_types=["instanceTypes"], launch_template=batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", overrides=[batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationOverrideProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", target_instance_types=["targetInstanceTypes"], userdata_type="userdataType", version="version" )], userdata_type="userdataType", version="version" ), maxv_cpus=123, minv_cpus=123, placement_group="placementGroup", security_group_ids=["securityGroupIds"], spot_iam_fleet_role="spotIamFleetRole", subnets=["subnets"], tags={ "tags_key": "tags" }, type="type", update_to_latest_image_version=False ), context="context", eks_configuration=batch_mixins.CfnComputeEnvironmentPropsMixin.EksConfigurationProperty( eks_cluster_arn="eksClusterArn", kubernetes_namespace="kubernetesNamespace" ), replace_compute_environment=False, service_role="serviceRole", state="state", tags={ "tags_key": "tags" }, type="type", unmanagedv_cpus=123, update_policy=batch_mixins.CfnComputeEnvironmentPropsMixin.UpdatePolicyProperty( job_execution_timeout_minutes=123, terminate_jobs_on_update=False ) ), strategy=mixins.PropertyMergeStrategy.OVERRIDE )
Create a mixin to apply properties to
AWS::Batch::ComputeEnvironment.- Parameters:
props (
Union[CfnComputeEnvironmentMixinProps,Dict[str,Any]]) – L1 properties to apply.strategy (
Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE
Methods
- apply_to(construct)
Apply the mixin properties to the construct.
- Parameters:
construct (
IConstruct)- Return type:
- supports(construct)
Check if this mixin supports the given construct.
- Parameters:
construct (
IConstruct)- Return type:
bool
Attributes
- CFN_PROPERTY_KEYS = ['computeEnvironmentName', 'computeResources', 'context', 'eksConfiguration', 'replaceComputeEnvironment', 'serviceRole', 'state', 'tags', 'type', 'unmanagedvCpus', 'updatePolicy']
Static Methods
- classmethod is_mixin(x)
(experimental) Checks if
xis a Mixin.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsMixin.- Stability:
experimental
ComputeResourcesProperty
- class CfnComputeEnvironmentPropsMixin.ComputeResourcesProperty(*, allocation_strategy=None, bid_percentage=None, desiredv_cpus=None, ec2_configuration=None, ec2_key_pair=None, image_id=None, instance_role=None, instance_types=None, launch_template=None, maxv_cpus=None, minv_cpus=None, placement_group=None, security_group_ids=None, spot_iam_fleet_role=None, subnets=None, tags=None, type=None, update_to_latest_image_version=None)
Bases:
objectDetails about the compute resources managed by the compute environment.
This parameter is required for managed compute environments. For more information, see Compute Environments in the AWS Batch User Guide .
- Parameters:
allocation_strategy (
Optional[str]) –The allocation strategy to use for the compute resource if not enough instances of the best fitting instance type can be allocated. This might be because of availability of the instance type in the Region or Amazon EC2 service limits . For more information, see Allocation strategies in the AWS Batch User Guide . When updating a compute environment, changing the allocation strategy requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .
BEST_FITis not supported when updating a compute environment. .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources, and shouldn’t be specified. - BEST_FIT (default) - AWS Batch selects an instance type that best fits the needs of the jobs with a preference for the lowest-cost instance type. If additional instances of the selected instance type aren’t available, AWS Batch waits for the additional instances to be available. If there aren’t enough instances available, or if the user is reaching Amazon EC2 service limits then additional jobs aren’t run until the currently running jobs have completed. This allocation strategy keeps costs lower but can limit scaling. If you are using Spot Fleets withBEST_FITthen the Spot Fleet IAM role must be specified. - BEST_FIT_PROGRESSIVE - AWS Batch will select additional instance types that are large enough to meet the requirements of the jobs in the queue, with a preference for instance types with a lower cost per unit vCPU. If additional instances of the previously selected instance types aren’t available, AWS Batch will select new instance types. - SPOT_CAPACITY_OPTIMIZED - AWS Batch will select one or more instance types that are large enough to meet the requirements of the jobs in the queue, with a preference for instance types that are less likely to be interrupted. This allocation strategy is only available for Spot Instance compute resources. - SPOT_PRICE_CAPACITY_OPTIMIZED - The price and capacity optimized allocation strategy looks at both price and capacity to select the Spot Instance pools that are the least likely to be interrupted and have the lowest possible price. This allocation strategy is only available for Spot Instance compute resources. .. epigraph:: We recommend that you useSPOT_PRICE_CAPACITY_OPTIMIZEDrather thanSPOT_CAPACITY_OPTIMIZEDin most instances. WithBEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZED, andSPOT_PRICE_CAPACITY_OPTIMIZEDallocation strategies using On-Demand or Spot Instances, and theBEST_FITstrategy using Spot Instances, AWS Batch might need to go abovemaxvCpusto meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpusby more than a single instance.bid_percentage (
Union[int,float,None]) –The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched. For example, if your maximum percentage is 20%, the Spot price must be less than 20% of the current On-Demand price for that Amazon EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. For most use cases, we recommend leaving this field empty. When updating a compute environment, changing the bid percentage requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.
desiredv_cpus (
Union[int,float,None]) – The desired number of vCPUS in the compute environment. AWS Batch modifies this value between the minimum and maximum values based on job queue demand. .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it. > AWS Batch doesn’t support changing the desired number of vCPUs of an existing compute environment. Don’t specify this parameter for compute environments using Amazon EKS clusters. > When you update thedesiredvCpussetting, the value must be between theminvCpusandmaxvCpusvalues. Additionally, the updateddesiredvCpusvalue must be greater than or equal to the currentdesiredvCpusvalue. For more information, see Troubleshooting AWS Batch in the AWS Batch User Guide .ec2_configuration (
Union[IResolvable,Sequence[Union[IResolvable,Ec2ConfigurationObjectProperty,Dict[str,Any]]],None]) –Provides information used to select Amazon Machine Images (AMIs) for Amazon EC2 instances in the compute environment. If
Ec2Configurationisn’t specified, the default isECS_AL2. When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . To remove the Amazon EC2 configuration and any custom AMI ID specified inimageIdOverride, set this value to an empty string. One or two values can be provided. .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.ec2_key_pair (
Optional[str]) –The Amazon EC2 key pair that’s used for instances launched in the compute environment. You can use this key pair to log in to your instances with SSH. To remove the Amazon EC2 key pair, set this value to an empty string. When updating a compute environment, changing the Amazon EC2 key pair requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.
image_id (
Optional[str]) –The Amazon Machine Image (AMI) ID used for instances launched in the compute environment. This parameter is overridden by the
imageIdOverridemember of theEc2Configurationstructure. To remove the custom AMI ID and use the default AMI ID, set this value to an empty string. When updating a compute environment, changing the AMI ID requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it. > The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see Amazon ECS-optimized Amazon Linux 2 AMI in the Amazon Elastic Container Service Developer Guide .instance_role (
Optional[str]) –The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment. Required for Amazon EC2 instances. You can specify the short name or full Amazon Resource Name (ARN) of an instance profile. For example,
*ecsInstanceRole*orarn:aws:iam:: *<aws_account_id>* :instance-profile/ *ecsInstanceRole*. For more information, see Amazon ECS instance role in the AWS Batch User Guide . When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.instance_types (
Optional[Sequence[str]]) – The instances types that can be launched. You can specify instance families to launch any instance type within those families (for example,c5orp3), or you can specify specific sizes within a family (such asc5.8xlarge). AWS Batch can select the instance type for you if you choose one of the following: -optimalto select instance types (from thec4,m4,r4,c5,m5, andr5instance families) that match the demand of your job queues. -default_x86_64to choose x86 based instance types (from them6i,c6i,r6i, andc7iinstance families) that matches the resource demands of the job queue. -default_arm64to choose x86 based instance types (from them6g,c6g,r6g, andc7ginstance families) that matches the resource demands of the job queue. .. epigraph:: Starting on 11/01/2025 the behavior ofoptimalis going to be changed to matchdefault_x86_64. During the change your instance families could be updated to a newer generation. You do not need to perform any actions for the upgrade to happen. For more information about change, see Optimal instance type configuration to receive automatic instance family updates . > Instance family availability varies by AWS Region . For example, some AWS Region s may not have any fourth generation instance families but have fifth and sixth generation instance families. When usingdefault_x86_64ordefault_arm64instance bundles, AWS Batch selects instance families based on a balance of cost-effectiveness and performance. While newer generation instances often provide better price-performance, AWS Batch may choose an earlier generation instance family if it provides the optimal combination of availability, cost, and performance for your workload. For example, in an AWS Region where both c6i and c7i instances are available, AWS Batch might select c6i instances if they offer better cost-effectiveness for your specific job requirements. For more information on AWS Batch instance types and AWS Region availability, see Instance type compute table in the AWS Batch User Guide . AWS Batch periodically updates your instances in default bundles to newer, more cost-effective options. Updates happen automatically without requiring any action from you. Your workloads continue running during updates with no interruption > This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it. > When you create a compute environment, the instance types that you select for the compute environment must share the same architecture. For example, you can’t mix x86 and ARM instances in the same compute environment.launch_template (
Union[IResolvable,LaunchTemplateSpecificationProperty,Dict[str,Any],None]) –The launch template to use for your compute resources. Any other compute resource parameters that you specify in a CreateComputeEnvironment API operation override the same parameters in the launch template. You must specify either the launch template ID or launch template name in the request, but not both. For more information, see Launch Template Support in the ** . Removing the launch template from a compute environment will not remove the AMI specified in the launch template. In order to update the AMI specified in a launch template, the
updateToLatestImageVersionparameter must be set totrue. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the ** . .. epigraph:: This parameter isn’t applicable to jobs running on Fargate resources, and shouldn’t be specified.maxv_cpus (
Union[int,float,None]) – The maximum number of Amazon EC2 vCPUs that an environment can reach. .. epigraph:: WithBEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZEDandSPOT_PRICE_CAPACITY_OPTIMIZED(recommended) strategies using On-Demand or Spot Instances, and theBEST_FITstrategy using Spot Instances, AWS Batch might need to exceedmaxvCpusto meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpusby more than a single instance.minv_cpus (
Union[int,float,None]) – The minimum number of vCPUs that an environment should maintain (even if the compute environment isDISABLED). .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.placement_group (
Optional[str]) –The Amazon EC2 placement group to associate with your compute resources. If you intend to submit multi-node parallel jobs to your compute environment, you should consider creating a cluster placement group and associate it with your compute resources. This keeps your multi-node parallel job on a logical grouping of instances within a single Availability Zone with high network flow potential. For more information, see Placement groups in the Amazon EC2 User Guide for Linux Instances . When updating a compute environment, changing the placement group requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.
security_group_ids (
Optional[Sequence[str]]) –The Amazon EC2 security groups that are associated with instances launched in the compute environment. This parameter is required for Fargate compute resources, where it can contain up to 5 security groups. For Fargate compute resources, providing an empty list is handled as if this parameter wasn’t specified and no change is made. For Amazon EC2 compute resources, providing an empty list removes the security groups from the compute resource. When updating a compute environment, changing the Amazon EC2 security groups requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .
spot_iam_fleet_role (
Optional[str]) – The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to aSPOTcompute environment. This role is required if the allocation strategy set toBEST_FITor if the allocation strategy isn’t specified. For more information, see Amazon EC2 spot fleet role in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it. > To tag your Spot Instances on creation, the Spot Fleet IAM role specified here must use the newer AmazonEC2SpotFleetTaggingRole managed policy. The previously recommended AmazonEC2SpotFleetRole managed policy doesn’t have the required permissions to tag Spot Instances. For more information, see Spot instances not tagged on creation in the AWS Batch User Guide .subnets (
Optional[Sequence[str]]) –The VPC subnets where the compute resources are launched. Fargate compute resources can contain up to 16 subnets. For Fargate compute resources, providing an empty list will be handled as if this parameter wasn’t specified and no change is made. For Amazon EC2 compute resources, providing an empty list removes the VPC subnets from the compute resource. For more information, see VPCs and subnets in the Amazon VPC User Guide . When updating a compute environment, changing the VPC subnets requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: AWS Batch on Amazon EC2 and AWS Batch on Amazon EKS support Local Zones. For more information, see Local Zones in the Amazon EC2 User Guide for Linux Instances , Amazon EKS and AWS Local Zones in the Amazon EKS User Guide and Amazon ECS clusters in Local Zones, Wavelength Zones, and AWS Outposts in the Amazon ECS Developer Guide . AWS Batch on Fargate doesn’t currently support Local Zones.
tags (
Optional[Mapping[str,str]]) –Key-value pair tags to be applied to Amazon EC2 resources that are launched in the compute environment. For AWS Batch , these take the form of
"String1": "String2", whereString1is the tag key andString2is the tag value (for example,{ "Name": "Batch Instance - C4OnDemand" }). This is helpful for recognizing your Batch instances in the Amazon EC2 console. These tags aren’t seen when using the AWS BatchListTagsForResourceAPI operation. When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.type (
Optional[str]) –The type of compute environment:
EC2,SPOT,FARGATE, orFARGATE_SPOT. For more information, see Compute environments in the AWS Batch User Guide . If you chooseSPOT, you must also specify an Amazon EC2 Spot Fleet role with thespotIamFleetRoleparameter. For more information, see Amazon EC2 spot fleet role in the AWS Batch User Guide . When updating compute environment, changing the type of a compute environment requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . When updating the type of a compute environment, changing betweenEC2andSPOTor betweenFARGATEandFARGATE_SPOTwill initiate an infrastructure update, but if you switch betweenEC2andFARGATE, CloudFormation will create a new compute environment.update_to_latest_image_version (
Union[bool,IResolvable,None]) –Specifies whether the AMI ID is updated to the latest one that’s supported by AWS Batch when the compute environment has an infrastructure update. The default value is
false. .. epigraph:: An AMI ID can either be specified in theimageIdorimageIdOverrideparameters or be determined by the launch template that’s specified in thelaunchTemplateparameter. If an AMI ID is specified any of these ways, this parameter is ignored. For more information about to update AMI IDs during an infrastructure update, see Updating the AMI ID in the AWS Batch User Guide . When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . Default: - false
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins compute_resources_property = batch_mixins.CfnComputeEnvironmentPropsMixin.ComputeResourcesProperty( allocation_strategy="allocationStrategy", bid_percentage=123, desiredv_cpus=123, ec2_configuration=[batch_mixins.CfnComputeEnvironmentPropsMixin.Ec2ConfigurationObjectProperty( image_id_override="imageIdOverride", image_kubernetes_version="imageKubernetesVersion", image_type="imageType" )], ec2_key_pair="ec2KeyPair", image_id="imageId", instance_role="instanceRole", instance_types=["instanceTypes"], launch_template=batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", overrides=[batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationOverrideProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", target_instance_types=["targetInstanceTypes"], userdata_type="userdataType", version="version" )], userdata_type="userdataType", version="version" ), maxv_cpus=123, minv_cpus=123, placement_group="placementGroup", security_group_ids=["securityGroupIds"], spot_iam_fleet_role="spotIamFleetRole", subnets=["subnets"], tags={ "tags_key": "tags" }, type="type", update_to_latest_image_version=False )
Attributes
- allocation_strategy
The allocation strategy to use for the compute resource if not enough instances of the best fitting instance type can be allocated.
This might be because of availability of the instance type in the Region or Amazon EC2 service limits . For more information, see Allocation strategies in the AWS Batch User Guide .
When updating a compute environment, changing the allocation strategy requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .
BEST_FITis not supported when updating a compute environment. .. epigraph:This parameter isn't applicable to jobs that are running on Fargate resources, and shouldn't be specified.
BEST_FIT (default) - AWS Batch selects an instance type that best fits the needs of the jobs with a preference for the lowest-cost instance type. If additional instances of the selected instance type aren’t available, AWS Batch waits for the additional instances to be available. If there aren’t enough instances available, or if the user is reaching Amazon EC2 service limits then additional jobs aren’t run until the currently running jobs have completed. This allocation strategy keeps costs lower but can limit scaling. If you are using Spot Fleets with
BEST_FITthen the Spot Fleet IAM role must be specified.BEST_FIT_PROGRESSIVE - AWS Batch will select additional instance types that are large enough to meet the requirements of the jobs in the queue, with a preference for instance types with a lower cost per unit vCPU. If additional instances of the previously selected instance types aren’t available, AWS Batch will select new instance types.
SPOT_CAPACITY_OPTIMIZED - AWS Batch will select one or more instance types that are large enough to meet the requirements of the jobs in the queue, with a preference for instance types that are less likely to be interrupted. This allocation strategy is only available for Spot Instance compute resources.
SPOT_PRICE_CAPACITY_OPTIMIZED - The price and capacity optimized allocation strategy looks at both price and capacity to select the Spot Instance pools that are the least likely to be interrupted and have the lowest possible price. This allocation strategy is only available for Spot Instance compute resources.
We recommend that you use
SPOT_PRICE_CAPACITY_OPTIMIZEDrather thanSPOT_CAPACITY_OPTIMIZEDin most instances.With
BEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZED, andSPOT_PRICE_CAPACITY_OPTIMIZEDallocation strategies using On-Demand or Spot Instances, and theBEST_FITstrategy using Spot Instances, AWS Batch might need to go abovemaxvCpusto meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpusby more than a single instance.
- bid_percentage
The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched.
For example, if your maximum percentage is 20%, the Spot price must be less than 20% of the current On-Demand price for that Amazon EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. For most use cases, we recommend leaving this field empty.
When updating a compute environment, changing the bid percentage requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- desiredv_cpus
The desired number of vCPUS in the compute environment.
AWS Batch modifies this value between the minimum and maximum values based on job queue demand. .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it. > AWS Batch doesn't support changing the desired number of vCPUs of an existing compute environment. Don't specify this parameter for compute environments using Amazon EKS clusters. > When you update the ``desiredvCpus`` setting, the value must be between the ``minvCpus`` and ``maxvCpus`` values. Additionally, the updated ``desiredvCpus`` value must be greater than or equal to the current ``desiredvCpus`` value. For more information, see `Troubleshooting AWS Batch <https://docs.aws.amazon.com/batch/latest/userguide/troubleshooting.html#error-desired-vcpus-update>`_ in the *AWS Batch User Guide* .
- ec2_configuration
Provides information used to select Amazon Machine Images (AMIs) for Amazon EC2 instances in the compute environment.
If
Ec2Configurationisn’t specified, the default isECS_AL2.When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . To remove the Amazon EC2 configuration and any custom AMI ID specified in
imageIdOverride, set this value to an empty string.One or two values can be provided. .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- ec2_key_pair
The Amazon EC2 key pair that’s used for instances launched in the compute environment.
You can use this key pair to log in to your instances with SSH. To remove the Amazon EC2 key pair, set this value to an empty string.
When updating a compute environment, changing the Amazon EC2 key pair requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- image_id
The Amazon Machine Image (AMI) ID used for instances launched in the compute environment.
This parameter is overridden by the
imageIdOverridemember of theEc2Configurationstructure. To remove the custom AMI ID and use the default AMI ID, set this value to an empty string.When updating a compute environment, changing the AMI ID requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it. > The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see `Amazon ECS-optimized Amazon Linux 2 AMI <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html#ecs-optimized-ami-linux-variants.html>`_ in the *Amazon Elastic Container Service Developer Guide* .
- instance_role
The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment.
Required for Amazon EC2 instances. You can specify the short name or full Amazon Resource Name (ARN) of an instance profile. For example,
*ecsInstanceRole*orarn:aws:iam:: *<aws_account_id>* :instance-profile/ *ecsInstanceRole*. For more information, see Amazon ECS instance role in the AWS Batch User Guide .When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- instance_types
The instances types that can be launched.
You can specify instance families to launch any instance type within those families (for example,
c5orp3), or you can specify specific sizes within a family (such asc5.8xlarge).AWS Batch can select the instance type for you if you choose one of the following:
optimalto select instance types (from thec4,m4,r4,c5,m5, andr5instance families) that match the demand of your job queues.default_x86_64to choose x86 based instance types (from them6i,c6i,r6i, andc7iinstance families) that matches the resource demands of the job queue.default_arm64to choose x86 based instance types (from them6g,c6g,r6g, andc7ginstance families) that matches the resource demands of the job queue.
Starting on 11/01/2025 the behavior of
optimalis going to be changed to matchdefault_x86_64. During the change your instance families could be updated to a newer generation. You do not need to perform any actions for the upgrade to happen. For more information about change, see Optimal instance type configuration to receive automatic instance family updates . > Instance family availability varies by AWS Region . For example, some AWS Region s may not have any fourth generation instance families but have fifth and sixth generation instance families.When using
default_x86_64ordefault_arm64instance bundles, AWS Batch selects instance families based on a balance of cost-effectiveness and performance. While newer generation instances often provide better price-performance, AWS Batch may choose an earlier generation instance family if it provides the optimal combination of availability, cost, and performance for your workload. For example, in an AWS Region where both c6i and c7i instances are available, AWS Batch might select c6i instances if they offer better cost-effectiveness for your specific job requirements. For more information on AWS Batch instance types and AWS Region availability, see Instance type compute table in the AWS Batch User Guide .AWS Batch periodically updates your instances in default bundles to newer, more cost-effective options. Updates happen automatically without requiring any action from you. Your workloads continue running during updates with no interruption > This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it. > When you create a compute environment, the instance types that you select for the compute environment must share the same architecture. For example, you can’t mix x86 and ARM instances in the same compute environment.
- launch_template
The launch template to use for your compute resources.
Any other compute resource parameters that you specify in a CreateComputeEnvironment API operation override the same parameters in the launch template. You must specify either the launch template ID or launch template name in the request, but not both. For more information, see Launch Template Support in the ** . Removing the launch template from a compute environment will not remove the AMI specified in the launch template. In order to update the AMI specified in a launch template, the
updateToLatestImageVersionparameter must be set totrue.When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the ** . .. epigraph:
This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified.
- maxv_cpus
The maximum number of Amazon EC2 vCPUs that an environment can reach.
With
BEST_FIT_PROGRESSIVE,SPOT_CAPACITY_OPTIMIZEDandSPOT_PRICE_CAPACITY_OPTIMIZED(recommended) strategies using On-Demand or Spot Instances, and theBEST_FITstrategy using Spot Instances, AWS Batch might need to exceedmaxvCpusto meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpusby more than a single instance.
- minv_cpus
The minimum number of vCPUs that an environment should maintain (even if the compute environment is
DISABLED).This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.
- placement_group
The Amazon EC2 placement group to associate with your compute resources.
If you intend to submit multi-node parallel jobs to your compute environment, you should consider creating a cluster placement group and associate it with your compute resources. This keeps your multi-node parallel job on a logical grouping of instances within a single Availability Zone with high network flow potential. For more information, see Placement groups in the Amazon EC2 User Guide for Linux Instances .
When updating a compute environment, changing the placement group requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- security_group_ids
The Amazon EC2 security groups that are associated with instances launched in the compute environment.
This parameter is required for Fargate compute resources, where it can contain up to 5 security groups. For Fargate compute resources, providing an empty list is handled as if this parameter wasn’t specified and no change is made. For Amazon EC2 compute resources, providing an empty list removes the security groups from the compute resource.
When updating a compute environment, changing the Amazon EC2 security groups requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .
- spot_iam_fleet_role
The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a
SPOTcompute environment.This role is required if the allocation strategy set to
BEST_FITor if the allocation strategy isn’t specified. For more information, see Amazon EC2 spot fleet role in the AWS Batch User Guide . .. epigraph:This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it. > To tag your Spot Instances on creation, the Spot Fleet IAM role specified here must use the newer *AmazonEC2SpotFleetTaggingRole* managed policy. The previously recommended *AmazonEC2SpotFleetRole* managed policy doesn't have the required permissions to tag Spot Instances. For more information, see `Spot instances not tagged on creation <https://docs.aws.amazon.com/batch/latest/userguide/troubleshooting.html#spot-instance-no-tag>`_ in the *AWS Batch User Guide* .
- subnets
The VPC subnets where the compute resources are launched.
Fargate compute resources can contain up to 16 subnets. For Fargate compute resources, providing an empty list will be handled as if this parameter wasn’t specified and no change is made. For Amazon EC2 compute resources, providing an empty list removes the VPC subnets from the compute resource. For more information, see VPCs and subnets in the Amazon VPC User Guide .
When updating a compute environment, changing the VPC subnets requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
AWS Batch on Amazon EC2 and AWS Batch on Amazon EKS support Local Zones. For more information, see `Local Zones <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-local-zones>`_ in the *Amazon EC2 User Guide for Linux Instances* , `Amazon EKS and AWS Local Zones <https://docs.aws.amazon.com/eks/latest/userguide/local-zones.html>`_ in the *Amazon EKS User Guide* and `Amazon ECS clusters in Local Zones, Wavelength Zones, and AWS Outposts <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-regions-zones.html#clusters-local-zones>`_ in the *Amazon ECS Developer Guide* . AWS Batch on Fargate doesn't currently support Local Zones.
- tags
Key-value pair tags to be applied to Amazon EC2 resources that are launched in the compute environment.
For AWS Batch , these take the form of
"String1": "String2", whereString1is the tag key andString2is the tag value (for example,{ "Name": "Batch Instance - C4OnDemand" }). This is helpful for recognizing your Batch instances in the Amazon EC2 console. These tags aren’t seen when using the AWS BatchListTagsForResourceAPI operation.When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- type
EC2,SPOT,FARGATE, orFARGATE_SPOT.For more information, see Compute environments in the AWS Batch User Guide .
If you choose
SPOT, you must also specify an Amazon EC2 Spot Fleet role with thespotIamFleetRoleparameter. For more information, see Amazon EC2 spot fleet role in the AWS Batch User Guide .When updating compute environment, changing the type of a compute environment requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .
When updating the type of a compute environment, changing between
EC2andSPOTor betweenFARGATEandFARGATE_SPOTwill initiate an infrastructure update, but if you switch betweenEC2andFARGATE, CloudFormation will create a new compute environment.
- update_to_latest_image_version
Specifies whether the AMI ID is updated to the latest one that’s supported by AWS Batch when the compute environment has an infrastructure update.
The default value is
false. .. epigraph:An AMI ID can either be specified in the ``imageId`` or ``imageIdOverride`` parameters or be determined by the launch template that's specified in the ``launchTemplate`` parameter. If an AMI ID is specified any of these ways, this parameter is ignored. For more information about to update AMI IDs during an infrastructure update, see `Updating the AMI ID <https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html#updating-compute-environments-ami>`_ in the *AWS Batch User Guide* .
When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .
Ec2ConfigurationObjectProperty
- class CfnComputeEnvironmentPropsMixin.Ec2ConfigurationObjectProperty(*, image_id_override=None, image_kubernetes_version=None, image_type=None)
Bases:
objectProvides information used to select Amazon Machine Images (AMIs) for instances in the compute environment.
If
Ec2Configurationisn’t specified, the default isECS_AL2( Amazon Linux 2 ). .. epigraph:This object isn't applicable to jobs that are running on Fargate resources.
- Parameters:
image_id_override (
Optional[str]) –The AMI ID used for instances launched in the compute environment that match the image type. This setting overrides the
imageIdset in thecomputeResourceobject. .. epigraph:: The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see Amazon ECS-optimized Amazon Linux 2 AMI in the Amazon Elastic Container Service Developer Guide .image_kubernetes_version (
Optional[str]) – The Kubernetes version for the compute environment. If you don’t specify a value, the latest version that AWS Batch supports is used.image_type (
Optional[str]) –The image type to match with the instance type to select an AMI. The supported values are different for
ECSandEKSresources. - ECS - If theimageIdOverrideparameter isn’t specified, then a recent Amazon ECS-optimized Amazon Linux 2 AMI (ECS_AL2) is used. If a new image type is specified in an update, but neither animageIdnor aimageIdOverrideparameter is specified, then the latest Amazon ECS optimized AMI for that image type that’s supported by AWS Batch is used. .. epigraph:: AWS will end support for Amazon ECS optimized AL2-optimized and AL2-accelerated AMIs. Starting in January 2026, AWS Batch will change the default AMI for new Amazon ECS compute environments from Amazon Linux 2 to Amazon Linux 2023. We recommend migrating AWS Batch Amazon ECS compute environments to Amazon Linux 2023 to maintain optimal performance and security. For more information on upgrading from AL2 to AL2023, see How to migrate from ECS AL2 to ECS AL2023 in the AWS Batch User Guide . - ECS_AL2 - Amazon Linux 2 : Default for all non-GPU instance families. - ECS_AL2_NVIDIA - Amazon Linux 2 (GPU) : Default for all GPU instance families (for exampleP4andG4) and can be used for all non AWS Graviton-based instance types. - ECS_AL2023 - Amazon Linux 2023 : AWS Batch supports Amazon Linux 2023. .. epigraph:: Amazon Linux 2023 does not supportA1instances. - ECS_AL2023_NVIDIA - Amazon Linux 2023 (GPU) : For all GPU instance families and can be used for all non AWS Graviton-based instance types. .. epigraph:: ECS_AL2023_NVIDIA doesn’t supportp3andg3instance types. - EKS - If theimageIdOverrideparameter isn’t specified, then a recent Amazon EKS-optimized Amazon Linux 2023 AMI (EKS_AL2023) is used. If a new image type is specified in an update, but neither animageIdnor aimageIdOverrideparameter is specified, then the latest Amazon EKS optimized AMI for that image type that AWS Batch supports is used. .. epigraph:: Amazon Linux 2023 AMIs are the default on AWS Batch for Amazon EKS. AWS will end support for Amazon EKS AL2-optimized and AL2-accelerated AMIs, starting 11/26/25. You can continue using AWS Batch -provided Amazon EKS optimized Amazon Linux 2 AMIs on your Amazon EKS compute environments beyond the 11/26/25 end-of-support date, these compute environments will no longer receive any new software updates, security patches, or bug fixes from AWS . For more information on upgrading from AL2 to AL2023, see How to upgrade from EKS AL2 to EKS AL2023 in the AWS Batch User Guide . - EKS_AL2 - Amazon Linux 2 : Used for non-GPU instance families. - EKS_AL2_NVIDIA - Amazon Linux 2 (accelerated) : Used for GPU instance families (for example,P4andG4) and can be used for all non AWS Graviton-based instance types. - EKS_AL2023 - Amazon Linux 2023 : Default for non-GPU instance families. .. epigraph:: Amazon Linux 2023 does not supportA1instances. - EKS_AL2023_NVIDIA - Amazon Linux 2023 (accelerated) : Default for GPU instance families and can be used for all non AWS Graviton-based instance types.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins ec2_configuration_object_property = batch_mixins.CfnComputeEnvironmentPropsMixin.Ec2ConfigurationObjectProperty( image_id_override="imageIdOverride", image_kubernetes_version="imageKubernetesVersion", image_type="imageType" )
Attributes
- image_id_override
The AMI ID used for instances launched in the compute environment that match the image type.
This setting overrides the
imageIdset in thecomputeResourceobject. .. epigraph:The AMI that you choose for a compute environment must match the architecture of the instance types that you intend to use for that compute environment. For example, if your compute environment uses A1 instance types, the compute resource AMI that you choose must support ARM instances. Amazon ECS vends both x86 and ARM versions of the Amazon ECS-optimized Amazon Linux 2 AMI. For more information, see `Amazon ECS-optimized Amazon Linux 2 AMI <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html#ecs-optimized-ami-linux-variants.html>`_ in the *Amazon Elastic Container Service Developer Guide* .
- image_kubernetes_version
The Kubernetes version for the compute environment.
If you don’t specify a value, the latest version that AWS Batch supports is used.
- image_type
The image type to match with the instance type to select an AMI.
The supported values are different for
ECSandEKSresources.ECS - If the
imageIdOverrideparameter isn’t specified, then a recent Amazon ECS-optimized Amazon Linux 2 AMI (ECS_AL2) is used. If a new image type is specified in an update, but neither animageIdnor aimageIdOverrideparameter is specified, then the latest Amazon ECS optimized AMI for that image type that’s supported by AWS Batch is used.
AWS will end support for Amazon ECS optimized AL2-optimized and AL2-accelerated AMIs. Starting in January 2026, AWS Batch will change the default AMI for new Amazon ECS compute environments from Amazon Linux 2 to Amazon Linux 2023. We recommend migrating AWS Batch Amazon ECS compute environments to Amazon Linux 2023 to maintain optimal performance and security. For more information on upgrading from AL2 to AL2023, see How to migrate from ECS AL2 to ECS AL2023 in the AWS Batch User Guide .
ECS_AL2 - Amazon Linux 2 : Default for all non-GPU instance families.
ECS_AL2_NVIDIA - Amazon Linux 2 (GPU) : Default for all GPU instance families (for example
P4andG4) and can be used for all non AWS Graviton-based instance types.ECS_AL2023 - Amazon Linux 2023 : AWS Batch supports Amazon Linux 2023.
Amazon Linux 2023 does not support
A1instances.ECS_AL2023_NVIDIA - Amazon Linux 2023 (GPU) : For all GPU instance families and can be used for all non AWS Graviton-based instance types.
ECS_AL2023_NVIDIA doesn’t support
p3andg3instance types.EKS - If the
imageIdOverrideparameter isn’t specified, then a recent Amazon EKS-optimized Amazon Linux 2023 AMI (EKS_AL2023) is used. If a new image type is specified in an update, but neither animageIdnor aimageIdOverrideparameter is specified, then the latest Amazon EKS optimized AMI for that image type that AWS Batch supports is used.
Amazon Linux 2023 AMIs are the default on AWS Batch for Amazon EKS.
AWS will end support for Amazon EKS AL2-optimized and AL2-accelerated AMIs, starting 11/26/25. You can continue using AWS Batch -provided Amazon EKS optimized Amazon Linux 2 AMIs on your Amazon EKS compute environments beyond the 11/26/25 end-of-support date, these compute environments will no longer receive any new software updates, security patches, or bug fixes from AWS . For more information on upgrading from AL2 to AL2023, see How to upgrade from EKS AL2 to EKS AL2023 in the AWS Batch User Guide .
EKS_AL2 - Amazon Linux 2 : Used for non-GPU instance families.
EKS_AL2_NVIDIA - Amazon Linux 2 (accelerated) : Used for GPU instance families (for example,
P4andG4) and can be used for all non AWS Graviton-based instance types.EKS_AL2023 - Amazon Linux 2023 : Default for non-GPU instance families.
Amazon Linux 2023 does not support
A1instances.EKS_AL2023_NVIDIA - Amazon Linux 2023 (accelerated) : Default for GPU instance families and can be used for all non AWS Graviton-based instance types.
EksConfigurationProperty
- class CfnComputeEnvironmentPropsMixin.EksConfigurationProperty(*, eks_cluster_arn=None, kubernetes_namespace=None)
Bases:
objectConfiguration for the Amazon EKS cluster that supports the AWS Batch compute environment.
The cluster must exist before the compute environment can be created.
- Parameters:
eks_cluster_arn (
Optional[str]) – The Amazon Resource Name (ARN) of the Amazon EKS cluster. An example isarn: *aws* :eks: *us-east-1* : *123456789012* :cluster/ *ClusterForBatch*.kubernetes_namespace (
Optional[str]) – The namespace of the Amazon EKS cluster. AWS Batch manages pods in this namespace. The value can’t left empty or null. It must be fewer than 64 characters long, can’t be set todefault, can’t start with “kube-,” and must match this regular expression:^[a-z0-9]([-a-z0-9]*[a-z0-9])?$. For more information, see Namespaces in the Kubernetes documentation.
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins eks_configuration_property = batch_mixins.CfnComputeEnvironmentPropsMixin.EksConfigurationProperty( eks_cluster_arn="eksClusterArn", kubernetes_namespace="kubernetesNamespace" )
Attributes
- eks_cluster_arn
The Amazon Resource Name (ARN) of the Amazon EKS cluster.
An example is
arn: *aws* :eks: *us-east-1* : *123456789012* :cluster/ *ClusterForBatch*.
- kubernetes_namespace
The namespace of the Amazon EKS cluster.
AWS Batch manages pods in this namespace. The value can’t left empty or null. It must be fewer than 64 characters long, can’t be set to
default, can’t start with “kube-,” and must match this regular expression:^[a-z0-9]([-a-z0-9]*[a-z0-9])?$. For more information, see Namespaces in the Kubernetes documentation.
LaunchTemplateSpecificationOverrideProperty
- class CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationOverrideProperty(*, launch_template_id=None, launch_template_name=None, target_instance_types=None, userdata_type=None, version=None)
Bases:
objectAn object that represents a launch template to use in place of the default launch template.
You must specify either the launch template ID or launch template name in the request, but not both.
If security groups are specified using both the
securityGroupIdsparameter ofCreateComputeEnvironmentand the launch template, the values in thesecurityGroupIdsparameter ofCreateComputeEnvironmentwill be used.You can define up to ten (10) overrides for each compute environment. .. epigraph:
This object isn't applicable to jobs that are running on Fargate resources. > To unset all override templates for a compute environment, you can pass an empty array to the `UpdateComputeEnvironment.overrides <https://docs.aws.amazon.com/batch/latest/APIReference/API_UpdateComputeEnvironment.html>`_ parameter, or not include the ``overrides`` parameter when submitting the ``UpdateComputeEnvironment`` API operation.
- Parameters:
launch_template_id (
Optional[str]) – The ID of the launch template. Note: If you specify thelaunchTemplateIdyou can’t specify thelaunchTemplateNameas well.launch_template_name (
Optional[str]) – The name of the launch template. Note: If you specify thelaunchTemplateNameyou can’t specify thelaunchTemplateIdas well.target_instance_types (
Optional[Sequence[str]]) – The instance type or family that this override launch template should be applied to. This parameter is required when defining a launch template override. Information included in this parameter must meet the following requirements: - Must be a valid Amazon EC2 instance type or family. - The following AWS BatchInstanceTypesare not allowed:optimal,default_x86_64, anddefault_arm64. -targetInstanceTypescan target only instance types and families that are included within the`ComputeResource.instanceTypes<https://docs.aws.amazon.com/batch/latest/APIReference/API_ComputeResource.html#Batch-Type-ComputeResource-instanceTypes>`_ set.targetInstanceTypesdoesn’t need to include all of the instances from theinstanceTypeset, but at least a subset. For example, ifComputeResource.instanceTypesincludes[m5, g5],targetInstanceTypescan include[m5.2xlarge]and[m5.large]but not[c5.large]. -targetInstanceTypesincluded within the same launch template override or across launch template overrides can’t overlap for the same compute environment. For example, you can’t define one launch template override to target an instance family and another define an instance type within this same family.userdata_type (
Optional[str]) – The EKS node initialization process to use. You only need to specify this value if you are using a custom AMI. The default value isEKS_BOOTSTRAP_SH. If imageType is a custom AMI based on EKS_AL2023 or EKS_AL2023_NVIDIA then you must chooseEKS_NODEADM.version (
Optional[str]) –The version number of the launch template,
$Default, or$Latest. If the value is$Default, the default version of the launch template is used. If the value is$Latest, the latest version of the launch template is used. .. epigraph:: If the AMI ID that’s used in a compute environment is from the launch template, the AMI isn’t changed when the compute environment is updated. It’s only changed if theupdateToLatestImageVersionparameter for the compute environment is set totrue. During an infrastructure update, if either$Defaultor$Latestis specified, AWS Batch re-evaluates the launch template version, and it might use a different version of the launch template. This is the case even if the launch template isn’t specified in the update. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . Default:$DefaultLatest:$Latest
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins launch_template_specification_override_property = batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationOverrideProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", target_instance_types=["targetInstanceTypes"], userdata_type="userdataType", version="version" )
Attributes
- launch_template_id
The ID of the launch template.
Note: If you specify the
launchTemplateIdyou can’t specify thelaunchTemplateNameas well.
- launch_template_name
The name of the launch template.
Note: If you specify the
launchTemplateNameyou can’t specify thelaunchTemplateIdas well.
- target_instance_types
The instance type or family that this override launch template should be applied to.
This parameter is required when defining a launch template override.
Information included in this parameter must meet the following requirements:
Must be a valid Amazon EC2 instance type or family.
The following AWS Batch
InstanceTypesare not allowed:optimal,default_x86_64, anddefault_arm64.targetInstanceTypescan target only instance types and families that are included within the`ComputeResource.instanceTypes<https://docs.aws.amazon.com/batch/latest/APIReference/API_ComputeResource.html#Batch-Type-ComputeResource-instanceTypes>`_ set.targetInstanceTypesdoesn’t need to include all of the instances from theinstanceTypeset, but at least a subset. For example, ifComputeResource.instanceTypesincludes[m5, g5],targetInstanceTypescan include[m5.2xlarge]and[m5.large]but not[c5.large].targetInstanceTypesincluded within the same launch template override or across launch template overrides can’t overlap for the same compute environment. For example, you can’t define one launch template override to target an instance family and another define an instance type within this same family.
- userdata_type
The EKS node initialization process to use.
You only need to specify this value if you are using a custom AMI. The default value is
EKS_BOOTSTRAP_SH. If imageType is a custom AMI based on EKS_AL2023 or EKS_AL2023_NVIDIA then you must chooseEKS_NODEADM.
- version
The version number of the launch template,
$Default, or$Latest.If the value is
$Default, the default version of the launch template is used. If the value is$Latest, the latest version of the launch template is used. .. epigraph:If the AMI ID that's used in a compute environment is from the launch template, the AMI isn't changed when the compute environment is updated. It's only changed if the ``updateToLatestImageVersion`` parameter for the compute environment is set to ``true`` . During an infrastructure update, if either ``$Default`` or ``$Latest`` is specified, AWS Batch re-evaluates the launch template version, and it might use a different version of the launch template. This is the case even if the launch template isn't specified in the update. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see `Updating compute environments <https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html>`_ in the *AWS Batch User Guide* .
Default:
$DefaultLatest:
$Latest
LaunchTemplateSpecificationProperty
- class CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationProperty(*, launch_template_id=None, launch_template_name=None, overrides=None, userdata_type=None, version=None)
Bases:
objectAn object that represents a launch template that’s associated with a compute resource.
You must specify either the launch template ID or launch template name in the request, but not both.
If security groups are specified using both the
securityGroupIdsparameter ofCreateComputeEnvironmentand the launch template, the values in thesecurityGroupIdsparameter ofCreateComputeEnvironmentwill be used. .. epigraph:This object isn't applicable to jobs that are running on Fargate resources.
- Parameters:
launch_template_id (
Optional[str]) – The ID of the launch template.launch_template_name (
Optional[str]) – The name of the launch template.overrides (
Union[IResolvable,Sequence[Union[IResolvable,LaunchTemplateSpecificationOverrideProperty,Dict[str,Any]]],None]) – A launch template to use in place of the default launch template. You must specify either the launch template ID or launch template name in the request, but not both. You can specify up to ten (10) launch template overrides that are associated to unique instance types or families for each compute environment. .. epigraph:: To unset all override templates for a compute environment, you can pass an empty array to the UpdateComputeEnvironment.overrides parameter, or not include theoverridesparameter when submitting theUpdateComputeEnvironmentAPI operation.userdata_type (
Optional[str]) – The EKS node initialization process to use. You only need to specify this value if you are using a custom AMI. The default value isEKS_BOOTSTRAP_SH. If imageType is a custom AMI based on EKS_AL2023 or EKS_AL2023_NVIDIA then you must chooseEKS_NODEADM.version (
Optional[str]) –The version number of the launch template,
$Default, or$Latest. If the value is$Default, the default version of the launch template is used. If the value is$Latest, the latest version of the launch template is used. .. epigraph:: If the AMI ID that’s used in a compute environment is from the launch template, the AMI isn’t changed when the compute environment is updated. It’s only changed if theupdateToLatestImageVersionparameter for the compute environment is set totrue. During an infrastructure update, if either$Defaultor$Latestis specified, AWS Batch re-evaluates the launch template version, and it might use a different version of the launch template. This is the case even if the launch template isn’t specified in the update. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . Default:$DefaultLatest:$Latest
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins launch_template_specification_property = batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", overrides=[batch_mixins.CfnComputeEnvironmentPropsMixin.LaunchTemplateSpecificationOverrideProperty( launch_template_id="launchTemplateId", launch_template_name="launchTemplateName", target_instance_types=["targetInstanceTypes"], userdata_type="userdataType", version="version" )], userdata_type="userdataType", version="version" )
Attributes
- launch_template_id
The ID of the launch template.
- launch_template_name
The name of the launch template.
- overrides
A launch template to use in place of the default launch template.
You must specify either the launch template ID or launch template name in the request, but not both.
You can specify up to ten (10) launch template overrides that are associated to unique instance types or families for each compute environment. .. epigraph:
To unset all override templates for a compute environment, you can pass an empty array to the `UpdateComputeEnvironment.overrides <https://docs.aws.amazon.com/batch/latest/APIReference/API_UpdateComputeEnvironment.html>`_ parameter, or not include the ``overrides`` parameter when submitting the ``UpdateComputeEnvironment`` API operation.
- userdata_type
The EKS node initialization process to use.
You only need to specify this value if you are using a custom AMI. The default value is
EKS_BOOTSTRAP_SH. If imageType is a custom AMI based on EKS_AL2023 or EKS_AL2023_NVIDIA then you must chooseEKS_NODEADM.
- version
The version number of the launch template,
$Default, or$Latest.If the value is
$Default, the default version of the launch template is used. If the value is$Latest, the latest version of the launch template is used. .. epigraph:If the AMI ID that's used in a compute environment is from the launch template, the AMI isn't changed when the compute environment is updated. It's only changed if the ``updateToLatestImageVersion`` parameter for the compute environment is set to ``true`` . During an infrastructure update, if either ``$Default`` or ``$Latest`` is specified, AWS Batch re-evaluates the launch template version, and it might use a different version of the launch template. This is the case even if the launch template isn't specified in the update. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see `Updating compute environments <https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html>`_ in the *AWS Batch User Guide* .
Default:
$DefaultLatest:
$Latest
UpdatePolicyProperty
- class CfnComputeEnvironmentPropsMixin.UpdatePolicyProperty(*, job_execution_timeout_minutes=None, terminate_jobs_on_update=None)
Bases:
objectSpecifies the infrastructure update policy for the Amazon EC2 compute environment.
For more information about infrastructure updates, see Updating compute environments in the AWS Batch User Guide .
- Parameters:
job_execution_timeout_minutes (
Union[int,float,None]) – Specifies the job timeout (in minutes) when the compute environment infrastructure is updated. The default value is 30. Default: - 30terminate_jobs_on_update (
Union[bool,IResolvable,None]) – Specifies whether jobs are automatically terminated when the compute environment infrastructure is updated. The default value isfalse. Default: - false
- See:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. from aws_cdk.mixins_preview.aws_batch import mixins as batch_mixins update_policy_property = batch_mixins.CfnComputeEnvironmentPropsMixin.UpdatePolicyProperty( job_execution_timeout_minutes=123, terminate_jobs_on_update=False )
Attributes
- job_execution_timeout_minutes
Specifies the job timeout (in minutes) when the compute environment infrastructure is updated.
The default value is 30.
- terminate_jobs_on_update
Specifies whether jobs are automatically terminated when the compute environment infrastructure is updated.
The default value is
false.