CfnComputeEnvironment

class aws_cdk.aws_batch.CfnComputeEnvironment(scope, id, *, type, compute_environment_name=None, compute_resources=None, eks_configuration=None, replace_compute_environment=None, service_role=None, state=None, tags=None, unmanagedv_cpus=None, update_policy=None)

Bases: CfnResource

The AWS::Batch::ComputeEnvironment resource defines your AWS Batch compute environment.

You can define MANAGED or UNMANAGED compute environments. MANAGED compute environments can use Amazon EC2 or AWS Fargate resources. UNMANAGED compute 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:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-batch-computeenvironment.html

CloudformationResource:

AWS::Batch::ComputeEnvironment

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 import aws_batch as batch

cfn_compute_environment = batch.CfnComputeEnvironment(self, "MyCfnComputeEnvironment",
    type="type",

    # the properties below are optional
    compute_environment_name="computeEnvironmentName",
    compute_resources=batch.CfnComputeEnvironment.ComputeResourcesProperty(
        maxv_cpus=123,
        subnets=["subnets"],
        type="type",

        # the properties below are optional
        allocation_strategy="allocationStrategy",
        bid_percentage=123,
        desiredv_cpus=123,
        ec2_configuration=[batch.CfnComputeEnvironment.Ec2ConfigurationObjectProperty(
            image_type="imageType",

            # the properties below are optional
            image_id_override="imageIdOverride",
            image_kubernetes_version="imageKubernetesVersion"
        )],
        ec2_key_pair="ec2KeyPair",
        image_id="imageId",
        instance_role="instanceRole",
        instance_types=["instanceTypes"],
        launch_template=batch.CfnComputeEnvironment.LaunchTemplateSpecificationProperty(
            launch_template_id="launchTemplateId",
            launch_template_name="launchTemplateName",
            version="version"
        ),
        minv_cpus=123,
        placement_group="placementGroup",
        security_group_ids=["securityGroupIds"],
        spot_iam_fleet_role="spotIamFleetRole",
        tags={
            "tags_key": "tags"
        },
        update_to_latest_image_version=False
    ),
    eks_configuration=batch.CfnComputeEnvironment.EksConfigurationProperty(
        eks_cluster_arn="eksClusterArn",
        kubernetes_namespace="kubernetesNamespace"
    ),
    replace_compute_environment=False,
    service_role="serviceRole",
    state="state",
    tags={
        "tags_key": "tags"
    },
    unmanagedv_cpus=123,
    update_policy=batch.CfnComputeEnvironment.UpdatePolicyProperty(
        job_execution_timeout_minutes=123,
        terminate_jobs_on_update=False
    )
)
Parameters:

Methods

add_deletion_override(path)

Syntactic sugar for addOverride(path, undefined).

Parameters:

path (str) – The path of the value to delete.

Return type:

None

add_dependency(target)

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

Parameters:

target (CfnResource) –

Return type:

None

add_depends_on(target)

(deprecated) Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

Parameters:

target (CfnResource) –

Deprecated:

use addDependency

Stability:

deprecated

Return type:

None

add_metadata(key, value)

Add a value to the CloudFormation Resource Metadata.

Parameters:
  • key (str) –

  • value (Any) –

See:

Return type:

None

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.

add_override(path, value)

Adds an override to the synthesized CloudFormation resource.

To add a property override, either use addPropertyOverride or prefix path with “Properties.” (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example:

cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"])
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")

would add the overrides Example:

"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters:
  • path (str) –

    • The path of the property, you can use dot notation to override values in complex types. Any intermediate keys will be created as needed.

  • value (Any) –

    • The value. Could be primitive or complex.

Return type:

None

add_property_deletion_override(property_path)

Adds an override that deletes the value of a property from the resource definition.

Parameters:

property_path (str) – The path to the property.

Return type:

None

add_property_override(property_path, value)

Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

Parameters:
  • property_path (str) – The path of the property.

  • value (Any) – The value.

Return type:

None

apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)

Sets the deletion policy of the resource based on the removal policy specified.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

Parameters:
  • policy (Optional[RemovalPolicy]) –

  • apply_to_update_replace_policy (Optional[bool]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: true

  • default (Optional[RemovalPolicy]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resource, please consult that specific resource’s documentation.

See:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html#aws-attribute-deletionpolicy-options

Return type:

None

get_att(attribute_name, type_hint=None)

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

Parameters:
  • attribute_name (str) – The name of the attribute.

  • type_hint (Optional[ResolutionTypeHint]) –

Return type:

Reference

get_metadata(key)

Retrieve a value value from the CloudFormation Resource Metadata.

Parameters:

key (str) –

See:

Return type:

Any

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.

inspect(inspector)

Examines the CloudFormation resource and discloses attributes.

Parameters:

inspector (TreeInspector) – tree inspector to collect and process attributes.

Return type:

None

obtain_dependencies()

Retrieves an array of resources this resource depends on.

This assembles dependencies on resources across stacks (including nested stacks) automatically.

Return type:

List[Union[Stack, CfnResource]]

obtain_resource_dependencies()

Get a shallow copy of dependencies between this resource and other resources in the same stack.

Return type:

List[CfnResource]

override_logical_id(new_logical_id)

Overrides the auto-generated logical ID with a specific ID.

Parameters:

new_logical_id (str) – The new logical ID to use for this stack element.

Return type:

None

remove_dependency(target)

Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

Parameters:

target (CfnResource) –

Return type:

None

replace_dependency(target, new_target)

Replaces one dependency with another.

Parameters:
Return type:

None

to_string()

Returns a string representation of this construct.

Return type:

str

Returns:

a string representation of this resource

Attributes

CFN_RESOURCE_TYPE_NAME = 'AWS::Batch::ComputeEnvironment'
attr_compute_environment_arn

Returns the compute environment ARN, such as batch: *us-east-1* : *111122223333* :compute-environment/ *ComputeEnvironmentName* .

CloudformationAttribute:

ComputeEnvironmentArn

cfn_options

Options for this resource, such as condition, update policy etc.

cfn_resource_type

AWS resource type.

compute_environment_name

The name for your compute environment.

compute_resources

The ComputeResources property type specifies details of the compute resources managed by the compute environment.

creation_stack

return:

the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.

eks_configuration

The details for the Amazon EKS cluster that supports the compute environment.

logical_id

The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Returns:

the logical ID as a stringified token. This value will only get resolved during synthesis.

node

The tree node.

ref

Return a string that will be resolved to a CloudFormation { Ref } for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

replace_compute_environment

Specifies whether the compute environment is replaced if an update is made that requires replacing the instances in the compute environment.

service_role

The full Amazon Resource Name (ARN) of the IAM role that allows AWS Batch to make calls to other AWS services on your behalf.

stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

state

The state of the compute environment.

tags

Tag Manager which manages the tags for this resource.

tags_raw

The tags applied to the compute environment.

type

MANAGED or UNMANAGED .

Type:

The type of the compute environment

unmanagedv_cpus

The maximum number of vCPUs for an unmanaged compute environment.

update_policy

Specifies the infrastructure update policy for the compute environment.

Static Methods

classmethod is_cfn_element(x)

Returns true if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

Parameters:

x (Any) –

Return type:

bool

Returns:

The construct as a stack element or undefined if it is not a stack element.

classmethod is_cfn_resource(x)

Check whether the given object is a CfnResource.

Parameters:

x (Any) –

Return type:

bool

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

ComputeResourcesProperty

class CfnComputeEnvironment.ComputeResourcesProperty(*, maxv_cpus, subnets, type, 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, minv_cpus=None, placement_group=None, security_group_ids=None, spot_iam_fleet_role=None, tags=None, update_to_latest_image_version=None)

Bases: object

Details 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:
  • maxv_cpus (Union[int, float]) – The maximum number of Amazon EC2 vCPUs that an environment can reach. .. epigraph:: With BEST_FIT_PROGRESSIVE , SPOT_CAPACITY_OPTIMIZED and SPOT_PRICE_CAPACITY_OPTIMIZED (recommended) strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, AWS Batch might need to exceed maxvCpus to meet your capacity requirements. In this event, AWS Batch never exceeds maxvCpus by more than a single instance.

  • subnets (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.

  • type (str) –

    The type of compute environment: EC2 , SPOT , FARGATE , or FARGATE_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 the spotIamFleetRole parameter. 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 EC2 and SPOT or between FARGATE and FARGATE_SPOT will initiate an infrastructure update, but if you switch between EC2 and FARGATE , AWS CloudFormation will create a new compute environment.

  • 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_FIT is 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_FIT then 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 use SPOT_PRICE_CAPACITY_OPTIMIZED rather than SPOT_CAPACITY_OPTIMIZED in most instances. With BEST_FIT_PROGRESSIVE , SPOT_CAPACITY_OPTIMIZED , and SPOT_PRICE_CAPACITY_OPTIMIZED allocation strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, AWS Batch might need to go above maxvCpus to meet your capacity requirements. In this event, AWS Batch never exceeds maxvCpus by 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 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 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 Ec2Configuration isn’t specified, the default is ECS_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 (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 imageIdOverride member of the Ec2Configuration structure. 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* or arn: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, c5 or p3 ), or you can specify specific sizes within a family (such as c5.8xlarge ). You can also choose optimal to select instance types (from the C4, M4, and R4 instance families) that match the demand of your job queues. 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. > 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. > Currently, optimal uses instance types from the C4, M4, and R4 instance families. In Regions that don’t have instance types from those instance families, instance types from the C5, M5, and R5 instance families are used.

  • 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 updateToLatestImageVersion parameter must be set to true . 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.

  • minv_cpus (Union[int, float, None]) – The minimum number of vCPUs that an environment should maintain (even if the compute environment is DISABLED ). .. 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 a SPOT compute environment. This role is required if the allocation strategy set to BEST_FIT or 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 .

  • 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" , where String1 is the tag key and String2 is 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 Batch ListTagsForResource API 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.

  • 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 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 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:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html

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 import aws_batch as batch

compute_resources_property = batch.CfnComputeEnvironment.ComputeResourcesProperty(
    maxv_cpus=123,
    subnets=["subnets"],
    type="type",

    # the properties below are optional
    allocation_strategy="allocationStrategy",
    bid_percentage=123,
    desiredv_cpus=123,
    ec2_configuration=[batch.CfnComputeEnvironment.Ec2ConfigurationObjectProperty(
        image_type="imageType",

        # the properties below are optional
        image_id_override="imageIdOverride",
        image_kubernetes_version="imageKubernetesVersion"
    )],
    ec2_key_pair="ec2KeyPair",
    image_id="imageId",
    instance_role="instanceRole",
    instance_types=["instanceTypes"],
    launch_template=batch.CfnComputeEnvironment.LaunchTemplateSpecificationProperty(
        launch_template_id="launchTemplateId",
        launch_template_name="launchTemplateName",
        version="version"
    ),
    minv_cpus=123,
    placement_group="placementGroup",
    security_group_ids=["securityGroupIds"],
    spot_iam_fleet_role="spotIamFleetRole",
    tags={
        "tags_key": "tags"
    },
    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_FIT is 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_FIT then 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_OPTIMIZED rather than SPOT_CAPACITY_OPTIMIZED in most instances.

With BEST_FIT_PROGRESSIVE , SPOT_CAPACITY_OPTIMIZED , and SPOT_PRICE_CAPACITY_OPTIMIZED allocation strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, AWS Batch might need to go above maxvCpus to meet your capacity requirements. In this event, AWS Batch never exceeds maxvCpus by more than a single instance.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-allocationstrategy

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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-bidpercentage

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* .
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-desiredvcpus

ec2_configuration

Provides information used to select Amazon Machine Images (AMIs) for Amazon EC2 instances in the compute environment.

If Ec2Configuration isn’t specified, the default is ECS_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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-ec2configuration

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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-ec2keypair

image_id

The Amazon Machine Image (AMI) ID used for instances launched in the compute environment.

This parameter is overridden by the imageIdOverride member of the Ec2Configuration structure. 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* .
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-imageid

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* or arn: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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-instancerole

instance_types

The instances types that can be launched.

You can specify instance families to launch any instance type within those families (for example, c5 or p3 ), or you can specify specific sizes within a family (such as c5.8xlarge ). You can also choose optimal to select instance types (from the C4, M4, and R4 instance families) that match the demand of your job queues.

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. > 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. > Currently, ``optimal`` uses instance types from the C4, M4, and R4 instance families. In Regions that don't have instance types from those instance families, instance types from the C5, M5, and R5 instance families are used.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-instancetypes

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 updateToLatestImageVersion parameter must be set to true .

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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-launchtemplate

maxv_cpus

The maximum number of Amazon EC2 vCPUs that an environment can reach.

With BEST_FIT_PROGRESSIVE , SPOT_CAPACITY_OPTIMIZED and SPOT_PRICE_CAPACITY_OPTIMIZED (recommended) strategies using On-Demand or Spot Instances, and the BEST_FIT strategy using Spot Instances, AWS Batch might need to exceed maxvCpus to meet your capacity requirements. In this event, AWS Batch never exceeds maxvCpus by more than a single instance.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-maxvcpus

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.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-minvcpus

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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-placementgroup

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 .

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-securitygroupids

spot_iam_fleet_role

The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a SPOT compute environment.

This role is required if the allocation strategy set to BEST_FIT or 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* .
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-spotiamfleetrole

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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-subnets

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" , where String1 is the tag key and String2 is 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 Batch ListTagsForResource API 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.
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-tags

type

EC2 , SPOT , FARGATE , or FARGATE_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 the spotIamFleetRole parameter. 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 EC2 and SPOT or between FARGATE and FARGATE_SPOT will initiate an infrastructure update, but if you switch between EC2 and FARGATE , AWS CloudFormation will create a new compute environment.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-type

Type:

The type of 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 .

Default:
  • false

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-updatetolatestimageversion

Ec2ConfigurationObjectProperty

class CfnComputeEnvironment.Ec2ConfigurationObjectProperty(*, image_type, image_id_override=None, image_kubernetes_version=None)

Bases: object

Provides information used to select Amazon Machine Images (AMIs) for instances in the compute environment.

If Ec2Configuration isn’t specified, the default is ECS_AL2 ( Amazon Linux 2 ). .. epigraph:

This object isn't applicable to jobs that are running on Fargate resources.
Parameters:
  • image_type (str) –

    The image type to match with the instance type to select an AMI. The supported values are different for ECS and EKS resources. - ECS - If the imageIdOverride parameter 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 an imageId nor a imageIdOverride parameter is specified, then the latest Amazon ECS optimized AMI for that image type that’s supported by AWS Batch is used. - 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 P4 and G4 ) 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 support A1 instances. - ECS_AL1 - Amazon Linux . Amazon Linux has reached the end-of-life of standard support. For more information, see Amazon Linux AMI . - EKS - If the imageIdOverride parameter isn’t specified, then a recent Amazon EKS-optimized Amazon Linux AMI ( EKS_AL2 ) is used. If a new image type is specified in an update, but neither an imageId nor a imageIdOverride parameter is specified, then the latest Amazon EKS optimized AMI for that image type that AWS Batch supports is used. - EKS_AL2 - Amazon Linux 2 : Default for all non-GPU instance families. - EKS_AL2_NVIDIA - Amazon Linux 2 (accelerated) : Default for all GPU instance families (for example, P4 and G4 ) and can be used for all non AWS Graviton-based instance types.

  • 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 imageId set in the computeResource object. .. 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.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-ec2configurationobject.html

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 import aws_batch as batch

ec2_configuration_object_property = batch.CfnComputeEnvironment.Ec2ConfigurationObjectProperty(
    image_type="imageType",

    # the properties below are optional
    image_id_override="imageIdOverride",
    image_kubernetes_version="imageKubernetesVersion"
)

Attributes

image_id_override

The AMI ID used for instances launched in the compute environment that match the image type.

This setting overrides the imageId set in the computeResource object. .. 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* .
See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-ec2configurationobject.html#cfn-batch-computeenvironment-ec2configurationobject-imageidoverride

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.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-ec2configurationobject.html#cfn-batch-computeenvironment-ec2configurationobject-imagekubernetesversion

image_type

The image type to match with the instance type to select an AMI.

The supported values are different for ECS and EKS resources.

  • ECS - If the imageIdOverride parameter 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 an imageId nor a imageIdOverride parameter is specified, then the latest Amazon ECS optimized AMI for that image type that’s supported by AWS Batch is used.

  • 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 P4 and G4 ) 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 A1 instances.

  • ECS_AL1 - Amazon Linux . Amazon Linux has reached the end-of-life of standard support. For more information, see Amazon Linux AMI .

  • EKS - If the imageIdOverride parameter isn’t specified, then a recent Amazon EKS-optimized Amazon Linux AMI ( EKS_AL2 ) is used. If a new image type is specified in an update, but neither an imageId nor a imageIdOverride parameter is specified, then the latest Amazon EKS optimized AMI for that image type that AWS Batch supports is used.

  • EKS_AL2 - Amazon Linux 2 : Default for all non-GPU instance families.

  • EKS_AL2_NVIDIA - Amazon Linux 2 (accelerated) : Default for all GPU instance families (for example, P4 and G4 ) and can be used for all non AWS Graviton-based instance types.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-ec2configurationobject.html#cfn-batch-computeenvironment-ec2configurationobject-imagetype

EksConfigurationProperty

class CfnComputeEnvironment.EksConfigurationProperty(*, eks_cluster_arn, kubernetes_namespace)

Bases: object

Configuration 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 (str) – The Amazon Resource Name (ARN) of the Amazon EKS cluster. An example is arn: *aws* :eks: *us-east-1* : *123456789012* :cluster/ *ClusterForBatch* .

  • kubernetes_namespace (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 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.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-eksconfiguration.html

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 import aws_batch as batch

eks_configuration_property = batch.CfnComputeEnvironment.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* .

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-eksconfiguration.html#cfn-batch-computeenvironment-eksconfiguration-eksclusterarn

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.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-eksconfiguration.html#cfn-batch-computeenvironment-eksconfiguration-kubernetesnamespace

LaunchTemplateSpecificationProperty

class CfnComputeEnvironment.LaunchTemplateSpecificationProperty(*, launch_template_id=None, launch_template_name=None, version=None)

Bases: object

An 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 securityGroupIds parameter of CreateComputeEnvironment and the launch template, the values in the securityGroupIds parameter of CreateComputeEnvironment will 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.

  • version (Optional[str]) –

    The version number of the launch template, $Latest , or $Default . If the value is $Latest , the latest version of the launch template is used. If the value is $Default , the default 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 $Latest or $Default 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 in the AWS Batch User Guide . Default: $Default .

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html

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 import aws_batch as batch

launch_template_specification_property = batch.CfnComputeEnvironment.LaunchTemplateSpecificationProperty(
    launch_template_id="launchTemplateId",
    launch_template_name="launchTemplateName",
    version="version"
)

Attributes

launch_template_id

The ID of the launch template.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html#cfn-batch-computeenvironment-launchtemplatespecification-launchtemplateid

launch_template_name

The name of the launch template.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html#cfn-batch-computeenvironment-launchtemplatespecification-launchtemplatename

version

The version number of the launch template, $Latest , or $Default .

If the value is $Latest , the latest version of the launch template is used. If the value is $Default , the default 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 ``$Latest`` or ``$Default`` 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: $Default .

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-launchtemplatespecification.html#cfn-batch-computeenvironment-launchtemplatespecification-version

UpdatePolicyProperty

class CfnComputeEnvironment.UpdatePolicyProperty(*, job_execution_timeout_minutes=None, terminate_jobs_on_update=None)

Bases: object

Specifies the infrastructure update policy for the 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: - 30

  • terminate_jobs_on_update (Union[bool, IResolvable, None]) – Specifies whether jobs are automatically terminated when the computer environment infrastructure is updated. The default value is false . Default: - false

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-updatepolicy.html

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 import aws_batch as batch

update_policy_property = batch.CfnComputeEnvironment.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.

Default:
  • 30

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-updatepolicy.html#cfn-batch-computeenvironment-updatepolicy-jobexecutiontimeoutminutes

terminate_jobs_on_update

Specifies whether jobs are automatically terminated when the computer environment infrastructure is updated.

The default value is false .

Default:
  • false

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-updatepolicy.html#cfn-batch-computeenvironment-updatepolicy-terminatejobsonupdate