CfnComputeEnvironment

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

Bases: CfnResource

A CloudFormation AWS::Batch::ComputeEnvironment.

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:

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 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`` .
- 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`` .
- 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.
CloudformationResource

AWS::Batch::ComputeEnvironment

Link

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

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.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"
        )],
        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
    ),
    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
    )
)

Create a new AWS::Batch::ComputeEnvironment.

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_depends_on(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_metadata(key, value)

Add a value to the CloudFormation Resource Metadata.

Parameters
  • key (str) –

  • value (Any) –

See

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.

Return type

None

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 intermdediate 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).

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 resoure, please consult that specific resource’s documentation.

Return type

None

get_att(attribute_name)

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.

Return type

Reference

get_metadata(key)

Retrieve a value value from the CloudFormation Resource Metadata.

Parameters

key (str) –

See

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.

Return type

Any

inspect(inspector)

Examines the CloudFormation resource and discloses attributes.

Parameters

inspector (TreeInspector) –

  • tree inspector to collect and process attributes.

Return type

None

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

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

Return type

str

cfn_options

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

Return type

ICfnResourceOptions

cfn_resource_type

AWS resource type.

Return type

str

compute_environment_name

The name for your compute environment.

It can be up to 128 letters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

Link

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

Return type

Optional[str]

compute_resources

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

This parameter is required for managed compute environments. For more information, see Compute Environments in the ** .

Link

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

Return type

Union[ComputeResourcesProperty, IResolvable, None]

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.

Return type

List[str]

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).

Return type

str

Returns

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

node

The construct tree node associated with this construct.

Return type

ConstructNode

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 }).

Return type

str

replace_compute_environment

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

The default value is true . To enable more properties to be updated, set this property to false . When changing the value of this property to false , no other properties should be changed at the same time. If other properties are changed at the same time, and the change needs to be rolled back but it can’t, it’s possible for the stack to go into the UPDATE_ROLLBACK_FAILED state. You can’t update a stack that is in the UPDATE_ROLLBACK_FAILED state. However, if you can continue to roll it back, you can return the stack to its original settings and then try to update it again. For more information, see Continue rolling back an update in the AWS CloudFormation User Guide .

The properties that can’t be changed without replacing the compute environment are in the `ComputeResources <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html>`_ property type: `AllocationStrategy <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-allocationstrategy>`_ , `BidPercentage <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-bidpercentage>`_ , `Ec2Configuration <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-ec2configuration>`_ , `Ec2KeyPair <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-ec2keypair>`_ , `Ec2KeyPair <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-ec2keypair>`_ , `ImageId <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-imageid>`_ , `InstanceRole <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-instancerole>`_ , `InstanceTypes <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-instancetypes>`_ , `LaunchTemplate <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-launchtemplate>`_ , `MaxvCpus <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-maxvcpus>`_ , `MinvCpus <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-minvcpus>`_ , `PlacementGroup <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-placementgroup>`_ , `SecurityGroupIds <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-securitygroupids>`_ , `Subnets <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-subnets>`_ , Tags , `Type <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-type>`_ , and `UpdateToLatestImageVersion <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-batch-computeenvironment-computeresources.html#cfn-batch-computeenvironment-computeresources-updatetolatestimageversion>`_ .

Link

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

Return type

Union[bool, IResolvable, None]

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.

For more information, see AWS Batch service IAM role in the AWS Batch User Guide . .. epigraph:

If your account already created the AWS Batch service-linked role, that role is used by default for your compute environment unless you specify a different role here. If the AWS Batch service-linked role doesn't exist in your account, and no role is specified here, the service attempts to create the AWS Batch service-linked role in your account.

If your specified role has a path other than / , then you must specify either the full role ARN (recommended) or prefix the role name with the path. For example, if a role with the name bar has a path of /foo/ then you would specify /foo/bar as the role name. For more information, see Friendly names and paths in the IAM User Guide . .. epigraph:

Depending on how you created your AWS Batch service role, its ARN might contain the ``service-role`` path prefix. When you only specify the name of the service role, AWS Batch assumes that your ARN doesn't use the ``service-role`` path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.
Link

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

Return type

Optional[str]

stack

The stack in which this element is defined.

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

Return type

Stack

state

The state of the compute environment.

If the state is ENABLED , then the compute environment accepts jobs from a queue and can scale out automatically based on queues.

If the state is ENABLED , then the AWS Batch scheduler can attempt to place jobs from an associated job queue on the compute resources within the environment. If the compute environment is managed, then it can scale its instances out or in automatically, based on the job queue demand.

If the state is DISABLED , then the AWS Batch scheduler doesn’t attempt to place jobs within the environment. Jobs in a STARTING or RUNNING state continue to progress normally. Managed compute environments in the DISABLED state don’t scale out. However, they scale in to minvCpus value after instances become idle.

Link

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

Return type

Optional[str]

tags

The tags applied to the compute environment.

Link

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

Return type

TagManager

type

MANAGED or UNMANAGED .

For more information, see Compute Environments in the AWS Batch User Guide .

Link

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

Type

The type of the compute environment

Return type

str

unmanagedv_cpus

The maximum number of vCPUs for an unmanaged compute environment.

This parameter is only used for fair share scheduling to reserve vCPU capacity for new share identifiers. If this parameter isn’t provided for a fair share job queue, no vCPU capacity is reserved. .. epigraph:

This parameter is only supported when the ``type`` parameter is set to ``UNMANAGED`` .
Link

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

Return type

Union[int, float, None]

update_policy

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 .

Link

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

Return type

Union[IResolvable, UpdatePolicyProperty, None]

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(construct)

Check whether the given construct is a CfnResource.

Parameters

construct (IConstruct) –

Return type

bool

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool

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 both BEST_FIT_PROGRESSIVE and SPOT_CAPACITY_OPTIMIZED allocation strategies, 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. That is, no more than a single instance from among those specified in your compute environment.

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

  • 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. With both BEST_FIT_PROGRESSIVE and SPOT_CAPACITY_OPTIMIZED strategies, 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%, then 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. 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, and shouldn’t be specified.

  • desiredv_cpus (Union[int, float, None]) – The desired number of Amazon EC2 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, and shouldn’t be specified.

  • ec2_configuration (Union[IResolvable, Sequence[Union[IResolvable, Ec2ConfigurationObjectProperty, Dict[str, Any]]], None]) –

    Provides information used to select Amazon Machine Images (AMIs) for 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 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, and shouldn’t be specified.

  • 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 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, and shouldn’t be specified.

  • 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, and shouldn’t be specified. > 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. 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, and shouldn’t be specified.

  • 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, and shouldn’t be specified. > 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 ** . .. 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 Amazon EC2 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, and shouldn’t be specified.

  • 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, and shouldn’t be specified.

  • security_group_ids (Optional[Sequence[str]]) –

    The Amazon EC2 security groups 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 EC2 compute resources, providing an empty list removes the security groups from the compute resource. When updating a compute environment, changing the 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, and shouldn’t be specified. > 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 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 AWS 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, and shouldn’t be specified.

  • 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:: If an AMI ID is specified in the imageId or imageIdOverride parameters or by the launch template specified in the launchTemplate parameter, this parameter is ignored. For more information on updating 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 .

Link

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.
import aws_cdk.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"
    )],
    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.

With both BEST_FIT_PROGRESSIVE and SPOT_CAPACITY_OPTIMIZED strategies, 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.

Link

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

Return type

Optional[str]

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%, then 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.

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, and shouldn't be specified.
Link

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

Return type

Union[int, float, None]

desiredv_cpus

The desired number of Amazon EC2 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, and shouldn't be specified.
Link

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

Return type

Union[int, float, None]

ec2_configuration

Provides information used to select Amazon Machine Images (AMIs) for 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 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, and shouldn't be specified.
Link

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

Return type

Union[IResolvable, List[Union[IResolvable, Ec2ConfigurationObjectProperty]], None]

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 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, and shouldn't be specified.
Link

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

Return type

Optional[str]

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, and shouldn't be specified. > 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* .
Link

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

Return type

Optional[str]

instance_role

The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment.

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, and shouldn't be specified.
Link

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

Return type

Optional[str]

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, and shouldn't be specified. > 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.
Link

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

Return type

Optional[List[str]]

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

This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified.
Link

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

Return type

Union[IResolvable, LaunchTemplateSpecificationProperty, None]

maxv_cpus

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

With both BEST_FIT_PROGRESSIVE and SPOT_CAPACITY_OPTIMIZED allocation strategies, 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. That is, no more than a single instance from among those specified in your compute environment.

Link

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

Return type

Union[int, float]

minv_cpus

The minimum number of Amazon EC2 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, and shouldn’t be specified.

Link

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

Return type

Union[int, float, None]

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, and shouldn't be specified.
Link

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

Return type

Optional[str]

security_group_ids

The Amazon EC2 security groups 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 EC2 compute resources, providing an empty list removes the security groups from the compute resource.

When updating a compute environment, changing the EC2 security groups requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide .

Link

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

Return type

Optional[List[str]]

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, and shouldn't be specified. > 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* .
Link

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

Return type

Optional[str]

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

Link

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

Return type

List[str]

tags

Key-value pair tags to be applied to 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 AWS 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, and shouldn't be specified.
Link

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

Return type

Optional[Mapping[str, str]]

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.

Link

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

Return type

str

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:

If an AMI ID is specified in the ``imageId`` or ``imageIdOverride`` parameters or by the launch template specified in the ``launchTemplate`` parameter, this parameter is ignored. For more information on updating 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 .

Link

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

Return type

Union[bool, IResolvable, None]

Ec2ConfigurationObjectProperty

class CfnComputeEnvironment.Ec2ConfigurationObjectProperty(*, image_type, image_id_override=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. 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_AL1 - Amazon Linux . Amazon Linux is reaching the end-of-life of standard support. For more information, see Amazon Linux AMI .

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

Link

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

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

    # the properties below are optional
    image_id_override="imageIdOverride"
)

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* .
Link

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

Return type

Optional[str]

image_type

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

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_AL1 - Amazon Linux . Amazon Linux is reaching the end-of-life of standard support. For more information, see Amazon Linux AMI .

Link

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

Return type

str

LaunchTemplateSpecificationProperty

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

Bases: object

An object representing a launch template 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 .

Link

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.
import aws_cdk.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.

Link

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

Return type

Optional[str]

launch_template_name

The name of the launch template.

Link

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

Return type

Optional[str]

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 .

Link

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

Return type

Optional[str]

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 Infrastructure updates 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.

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

Link

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.
import aws_cdk.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.

Link

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

Return type

Union[int, float, None]

terminate_jobs_on_update

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

The default value is false .

Link

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

Return type

Union[bool, IResolvable, None]