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
A CloudFormation
AWS::Batch::ComputeEnvironment
.The
AWS::Batch::ComputeEnvironment
resource defines your AWS Batch compute environment. You can defineMANAGED
orUNMANAGED
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 ``false`` 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.
- CloudformationResource:
AWS::Batch::ComputeEnvironment
- Link:
- 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", 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 ) )
Create a new
AWS::Batch::ComputeEnvironment
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
type (
str
) –The type of the compute environment:
MANAGED
orUNMANAGED
. For more information, see Compute Environments in the AWS Batch User Guide .compute_environment_name (
Optional
[str
]) – The name for your compute environment. It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).compute_resources (
Union
[ComputeResourcesProperty
,Dict
[str
,Any
],IResolvable
,None
]) –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 ** .
eks_configuration (
Union
[IResolvable
,EksConfigurationProperty
,Dict
[str
,Any
],None
]) – The details for the Amazon EKS cluster that supports the compute environment.replace_compute_environment (
Union
[bool
,IResolvable
,None
]) – Specifies whether the compute environment is replaced if an update is made that requires replacing the instances in the compute environment. The default value istrue
. To enable more properties to be updated, set this property tofalse
. When changing the value of this property tofalse
, do not change any other properties 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 theUPDATE_ROLLBACK_FAILED
state. You can’t update a stack that is in theUPDATE_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>`_ .service_role (
Optional
[str
]) – 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 namebar
has a path of/foo/
, 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 theservice-role
path prefix. When you only specify the name of the service role, AWS Batch assumes that your ARN doesn’t use theservice-role
path prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.state (
Optional
[str
]) – The state of the compute environment. If the state isENABLED
, then the compute environment accepts jobs from a queue and can scale out automatically based on queues. If the state isENABLED
, 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 isDISABLED
, then the AWS Batch scheduler doesn’t attempt to place jobs within the environment. Jobs in aSTARTING
orRUNNING
state continue to progress normally. Managed compute environments in theDISABLED
state don’t scale out. .. epigraph:: Compute environments in aDISABLED
state may continue to incur billing charges. To prevent additional charges, turn off and then delete the compute environment. For more information, see State in the AWS Batch User Guide . When an instance is idle, the instance scales down to theminvCpus
value. However, the instance size doesn’t change. For example, consider ac5.8xlarge
instance with aminvCpus
value of4
and adesiredvCpus
value of36
. This instance doesn’t scale down to ac5.large
instance.tags (
Optional
[Mapping
[str
,str
]]) – The tags applied to the compute environment.unmanagedv_cpus (
Union
[int
,float
,None
]) – 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 thetype
parameter is set toUNMANAGED
.update_policy (
Union
[IResolvable
,UpdatePolicyProperty
,Dict
[str
,Any
],None
]) – 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 .
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:
- Return type:
None
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 prefixpath
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 toaddOverride
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: truedefault (
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:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
)- See:
- Return type:
Any
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
- 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
- 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.
It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).
- 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 ** .
- 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 construct tree node associated with this construct.
- 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.
The default value is
true
. To enable more properties to be updated, set this property tofalse
. When changing the value of this property tofalse
, do not change any other properties 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 theUPDATE_ROLLBACK_FAILED
state. You can’t update a stack that is in theUPDATE_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>`_ .
- 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 namebar
has a path of/foo/
, 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.
- 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.
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 aSTARTING
orRUNNING
state continue to progress normally. Managed compute environments in theDISABLED
state don’t scale out. .. epigraph:Compute environments in a ``DISABLED`` state may continue to incur billing charges. To prevent additional charges, turn off and then delete the compute environment. For more information, see `State <https://docs.aws.amazon.com/batch/latest/userguide/compute_environment_parameters.html#compute_environment_state>`_ in the *AWS Batch User Guide* .
When an instance is idle, the instance scales down to the
minvCpus
value. However, the instance size doesn’t change. For example, consider ac5.8xlarge
instance with aminvCpus
value of4
and adesiredvCpus
value of36
. This instance doesn’t scale down to ac5.large
instance.
- tags
The tags applied to the compute environment.
- type
MANAGED
orUNMANAGED
.For more information, see Compute Environments in the AWS Batch User Guide .
- Link:
- Type:
The type of the compute environment
- 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`` .
- 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 .
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 bothBEST_FIT_PROGRESSIVE
andSPOT_CAPACITY_OPTIMIZED
allocation strategies using On-Demand or Spot Instances, and theBEST_FIT
strategy using Spot Instances, AWS Batch might need to exceedmaxvCpus
to meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpus
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 . .. 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
, orFARGATE_SPOT
. For more information, see Compute environments in the AWS Batch User Guide . If you chooseSPOT
, you must also specify an Amazon EC2 Spot Fleet role with thespotIamFleetRole
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 betweenEC2
andSPOT
or betweenFARGATE
andFARGATE_SPOT
will initiate an infrastructure update, but if you switch betweenEC2
andFARGATE
, 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 withBEST_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 bothBEST_FIT_PROGRESSIVE
andSPOT_CAPACITY_OPTIMIZED
allocation strategies using On-Demand or Spot Instances, and theBEST_FIT
strategy using Spot Instances, AWS Batch might need to go abovemaxvCpus
to meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpus
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 thedesiredvCpus
setting, the value must be between theminvCpus
andmaxvCpus
values. Additionally, the updateddesiredvCpus
value must be greater than or equal to the currentdesiredvCpus
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 EC2 instances in the compute environment. If
Ec2Configuration
isn’t specified, the default isECS_AL2
. When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . To remove the EC2 configuration and any custom AMI ID specified inimageIdOverride
, set this value to an empty string. One or two values can be provided. .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.ec2_key_pair (
Optional
[str
]) –The Amazon EC2 key pair that’s used for instances launched in the compute environment. You can use this key pair to log in to your instances with SSH. To remove the Amazon EC2 key pair, set this value to an empty string. When updating a compute environment, changing the 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 theEc2Configuration
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. You can specify the short name or full Amazon Resource Name (ARN) of an instance profile. For example,
*ecsInstanceRole*
orarn:aws:iam:: *<aws_account_id>* :instance-profile/ *ecsInstanceRole*
. For more information, see Amazon ECS instance role in the AWS Batch User Guide . When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.instance_types (
Optional
[Sequence
[str
]]) –The instances types that can be launched. You can specify instance families to launch any instance type within those families (for example,
c5
orp3
), or you can specify specific sizes within a family (such asc5.8xlarge
). You can also chooseoptimal
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 totrue
. When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the ** . .. epigraph:: This parameter isn’t applicable to jobs running on Fargate resources, and shouldn’t be specified.minv_cpus (
Union
[int
,float
,None
]) – The minimum number of vCPUs that an environment should maintain (even if the compute environment isDISABLED
). .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.placement_group (
Optional
[str
]) –The Amazon EC2 placement group to associate with your compute resources. If you intend to submit multi-node parallel jobs to your compute environment, you should consider creating a cluster placement group and associate it with your compute resources. This keeps your multi-node parallel job on a logical grouping of instances within a single Availability Zone with high network flow potential. For more information, see Placement groups in the Amazon EC2 User Guide for Linux Instances . When updating a compute environment, changing the placement group requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:: This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.
security_group_ids (
Optional
[Sequence
[str
]]) –The Amazon EC2 security groups that are associated with instances launched in the compute environment. This parameter is required for Fargate compute resources, where it can contain up to 5 security groups. For Fargate compute resources, providing an empty list is handled as if this parameter wasn’t specified and no change is made. For 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 toBEST_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 EC2 resources that are launched in the compute environment. For AWS Batch , these take the form of
"String1": "String2"
, whereString1
is the tag key andString2
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 BatchListTagsForResource
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 theimageId
orimageIdOverride
parameters or be determined by the launch template that’s specified in thelaunchTemplate
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 .
- Link:
- 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", 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.
With both
BEST_FIT_PROGRESSIVE
andSPOT_CAPACITY_OPTIMIZED
allocation strategies using On-Demand or Spot Instances, and theBEST_FIT
strategy using Spot Instances, AWS Batch might need to go abovemaxvCpus
to meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpus
by more than a single instance.
- bid_percentage
The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched.
For example, if your maximum percentage is 20%, the Spot price must be less than 20% of the current On-Demand price for that Amazon EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. For most use cases, we recommend leaving this field empty.
When updating a compute environment, changing the bid percentage requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- desiredv_cpus
The desired number of vCPUS in the compute environment.
AWS Batch modifies this value between the minimum and maximum values based on job queue demand. .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it. > AWS Batch doesn't support changing the desired number of vCPUs of an existing compute environment. Don't specify this parameter for compute environments using Amazon EKS clusters. > When you update the ``desiredvCpus`` setting, the value must be between the ``minvCpus`` and ``maxvCpus`` values. Additionally, the updated ``desiredvCpus`` value must be greater than or equal to the current ``desiredvCpus`` value. For more information, see `Troubleshooting AWS Batch <https://docs.aws.amazon.com/batch/latest/userguide/troubleshooting.html#error-desired-vcpus-update>`_ in the *AWS Batch User Guide* .
- ec2_configuration
Provides information used to select Amazon Machine Images (AMIs) for EC2 instances in the compute environment.
If
Ec2Configuration
isn’t specified, the default isECS_AL2
.When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . To remove the EC2 configuration and any custom AMI ID specified in
imageIdOverride
, set this value to an empty string.One or two values can be provided. .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- ec2_key_pair
The Amazon EC2 key pair that’s used for instances launched in the compute environment.
You can use this key pair to log in to your instances with SSH. To remove the Amazon EC2 key pair, set this value to an empty string.
When updating a compute environment, changing the EC2 key pair requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- image_id
The Amazon Machine Image (AMI) ID used for instances launched in the compute environment.
This parameter is overridden by the
imageIdOverride
member of theEc2Configuration
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* .
- 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*
orarn:aws:iam:: *<aws_account_id>* :instance-profile/ *ecsInstanceRole*
. For more information, see Amazon ECS instance role in the AWS Batch User Guide .When updating a compute environment, changing this setting requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- instance_types
The instances types that can be launched.
You can specify instance families to launch any instance type within those families (for example,
c5
orp3
), or you can specify specific sizes within a family (such asc5.8xlarge
). You can also chooseoptimal
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
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 totrue
.When updating a compute environment, changing the launch template requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the ** . .. epigraph:
This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified.
- maxv_cpus
The maximum number of Amazon EC2 vCPUs that an environment can reach.
With both
BEST_FIT_PROGRESSIVE
andSPOT_CAPACITY_OPTIMIZED
allocation strategies using On-Demand or Spot Instances, and theBEST_FIT
strategy using Spot Instances, AWS Batch might need to exceedmaxvCpus
to meet your capacity requirements. In this event, AWS Batch never exceedsmaxvCpus
by more than a single instance. That is, no more than a single instance from among those specified in your compute environment.
- minv_cpus
The minimum number of vCPUs that an environment should maintain (even if the compute environment is
DISABLED
).This parameter isn’t applicable to jobs that are running on Fargate resources. Don’t specify it.
- placement_group
The Amazon EC2 placement group to associate with your compute resources.
If you intend to submit multi-node parallel jobs to your compute environment, you should consider creating a cluster placement group and associate it with your compute resources. This keeps your multi-node parallel job on a logical grouping of instances within a single Availability Zone with high network flow potential. For more information, see Placement groups in the Amazon EC2 User Guide for Linux Instances .
When updating a compute environment, changing the placement group requires an infrastructure update of the compute environment. For more information, see Updating compute environments in the AWS Batch User Guide . .. epigraph:
This parameter isn't applicable to jobs that are running on Fargate resources. Don't specify it.
- security_group_ids
The Amazon EC2 security groups that are associated with instances launched in the compute environment.
This parameter is required for Fargate compute resources, where it can contain up to 5 security groups. For Fargate compute resources, providing an empty list is handled as if this parameter wasn’t specified and no change is made. For 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
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* .
- 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 . .. epigraph:
AWS Batch on Amazon EC2 and AWS Batch on Amazon EKS support Local Zones. For more information, see `Local Zones <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-local-zones>`_ in the *Amazon EC2 User Guide for Linux Instances* , `Amazon EKS and AWS Local Zones <https://docs.aws.amazon.com/eks/latest/userguide/local-zones.html>`_ in the *Amazon EKS User Guide* and `Amazon ECS clusters in Local Zones, Wavelength Zones, and AWS Outposts <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-regions-zones.html#clusters-local-zones>`_ in the *Amazon ECS Developer Guide* . AWS Batch on Fargate doesn't currently support Local Zones.
- tags
Key-value pair tags to be applied to EC2 resources that are launched in the compute environment.
For AWS Batch , these take the form of
"String1": "String2"
, whereString1
is the tag key andString2
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 BatchListTagsForResource
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.
- type
EC2
,SPOT
,FARGATE
, orFARGATE_SPOT
.For more information, see Compute environments in the AWS Batch User Guide .
If you choose
SPOT
, you must also specify an Amazon EC2 Spot Fleet role with thespotIamFleetRole
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
andSPOT
or betweenFARGATE
andFARGATE_SPOT
will initiate an infrastructure update, but if you switch betweenEC2
andFARGATE
, AWS CloudFormation will create a new compute environment.- Link:
- 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 .
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 isECS_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
andEKS
resources. - ECS - If theimageIdOverride
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 animageId
nor aimageIdOverride
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 exampleP4
andG4
) and can be used for all non AWS Graviton-based instance types. - ECS_AL1 - Amazon Linux . Amazon Linux has reached the end-of-life of standard support. For more information, see Amazon Linux AMI . - EKS - If theimageIdOverride
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 animageId
nor aimageIdOverride
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
andG4
) 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 thecomputeResource
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.
- Link:
- 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", 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 thecomputeResource
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* .
- image_kubernetes_version
The Kubernetes version for the compute environment.
If you don’t specify a value, the latest version that AWS Batch supports is used.
- image_type
The image type to match with the instance type to select an AMI.
The supported values are different for
ECS
andEKS
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 animageId
nor aimageIdOverride
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
andG4
) and can be used for all non AWS Graviton-based instance types.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 animageId
nor aimageIdOverride
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
andG4
) and can be used for all non AWS Graviton-based instance types.
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 isarn: *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 todefault
, can’t start with “kube-
,” and must match this regular expression:^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
. For more information, see Namespaces in the Kubernetes documentation.
- Link:
- 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 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*
.
- 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.
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 ofCreateComputeEnvironment
and the launch template, the values in thesecurityGroupIds
parameter ofCreateComputeEnvironment
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 theupdateToLatestImageVersion
parameter for the compute environment is set totrue
. 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:
- 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.
- launch_template_name
The name of the launch template.
- 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
.
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.terminate_jobs_on_update (
Union
[bool
,IResolvable
,None
]) – Specifies whether jobs are automatically terminated when the computer environment infrastructure is updated. The default value isfalse
.
- Link:
- 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.
- terminate_jobs_on_update
Specifies whether jobs are automatically terminated when the computer environment infrastructure is updated.
The default value is
false
.