CfnComputeEnvironment L1 construct
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.
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 .
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
UpdateComputeEnvironentAPI lets you use theReplaceComputeEnvironmentproperty to dynamically update compute environment parameters such as the launch template or instance type without replacement. For more information, see Updating compute environments 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 property or set it to the AWSServiceRoleForBatch service-linked role.
- Set the AllocationStrategy property to
BEST_FIT_PROGRESSIVEorSPOT_CAPACITY_OPTIMIZED.- Set the ReplaceComputeEnvironment property to
false.Set the
ReplaceComputeEnvironmentproperty totrueif the compute environment uses theBEST_FITallocation strategy. > If theReplaceComputeEnvironmentproperty is set tofalse, you might receive an error message when you update the CFN template for a compute environment. This issue occurs if the updateddesiredvcpusvalue is less than the currentdesiredvcpusvalue. As a workaround, delete thedesiredvcpusvalue from the updated template or use theminvcpusproperty to manage the number of vCPUs. For information, see Error message when you update theDesiredvCpussetting .
- Set the UpdateToLatestImageVersion property to
true. This property is used when you update a compute environment. The UpdateToLatestImageVersion property is ignored when you create a compute environment.- Either do not specify an image ID in ImageId or ImageIdOverride properties, or in the launch template identified by the Launch Template 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
ImageIdorImageIdOverrideproperties, or the launch template identified by theLaunchTemplateproperties. 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 property of the LaunchTemplateSpecification is set to
$Latestor$Default, the latest or default version of the launch template will be evaluated up at the time of the infrastructure update, even if theLaunchTemplateSpecificationwas not updated.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_batch as batch } from 'aws-cdk-lib';
const cfnComputeEnvironment = new batch.CfnComputeEnvironment(this, 'MyCfnComputeEnvironment', {
type: 'type',
// the properties below are optional
computeEnvironmentName: 'computeEnvironmentName',
computeResources: {
maxvCpus: 123,
type: 'type',
// the properties below are optional
allocationStrategy: 'allocationStrategy',
bidPercentage: 123,
capacityTags: {
capacityTagsKey: 'capacityTags',
},
desiredvCpus: 123,
ec2Configuration: [{
imageType: 'imageType',
// the properties below are optional
batchImageStatus: 'batchImageStatus',
imageIdOverride: 'imageIdOverride',
imageKubernetesVersion: 'imageKubernetesVersion',
}],
ec2KeyPair: 'ec2KeyPair',
imageId: 'imageId',
instanceRole: 'instanceRole',
instanceTypes: ['instanceTypes'],
launchTemplate: {
launchTemplateId: 'launchTemplateId',
launchTemplateName: 'launchTemplateName',
overrides: [{
launchTemplateId: 'launchTemplateId',
launchTemplateName: 'launchTemplateName',
targetInstanceTypes: ['targetInstanceTypes'],
userdataType: 'userdataType',
version: 'version',
}],
userdataType: 'userdataType',
version: 'version',
},
managedInstancesProvider: {
infrastructureRoleArn: 'infrastructureRoleArn',
instanceLaunchTemplate: {
ec2InstanceProfileArn: 'ec2InstanceProfileArn',
networkConfiguration: {
securityGroups: ['securityGroups'],
subnets: ['subnets'],
},
// the properties below are optional
capacityOptionType: 'capacityOptionType',
capacityReservations: {
reservationGroupArn: 'reservationGroupArn',
reservationPreference: 'reservationPreference',
},
fipsEnabled: false,
instanceMetadataTagsPropagation: false,
instanceRequirements: {
allowedInstanceTypes: ['allowedInstanceTypes'],
},
localStorageConfiguration: {
useLocalStorage: false,
},
monitoring: 'monitoring',
storageConfiguration: {
storageSizeGiB: 123,
},
},
// the properties below are optional
infrastructureOptimization: {
scaleInAfter: 123,
},
propagateTags: 'propagateTags',
},
minvCpus: 123,
placementGroup: 'placementGroup',
scalingPolicy: {
minScaleDownDelayMinutes: 123,
},
securityGroupIds: ['securityGroupIds'],
spotIamFleetRole: 'spotIamFleetRole',
subnets: ['subnets'],
tags: {
tagsKey: 'tags',
},
updateToLatestImageVersion: false,
},
context: 'context',
ecsSettings: {
containerInsights: 'containerInsights',
},
eksConfiguration: {
eksClusterArn: 'eksClusterArn',
kubernetesNamespace: 'kubernetesNamespace',
// the properties below are optional
accessEntry: {
desiredState: 'desiredState',
status: 'status',
},
},
replaceComputeEnvironment: false,
serviceRole: 'serviceRole',
state: 'state',
tags: {
tagsKey: 'tags',
},
unmanagedvCpus: 123,
updatePolicy: {
jobExecutionTimeoutMinutes: 123,
terminateJobsOnUpdate: false,
},
});
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_batch as batch
cfn_compute_environment = batch.CfnComputeEnvironment(self, "MyCfnComputeEnvironment",
type="type",
# the properties below are optional
compute_environment_name="computeEnvironmentName",
compute_resources=batch.CfnComputeEnvironment.ComputeResourcesProperty(
maxv_cpus=123,
type="type",
# the properties below are optional
allocation_strategy="allocationStrategy",
bid_percentage=123,
capacity_tags={
"capacity_tags_key": "capacityTags"
},
desiredv_cpus=123,
ec2_configuration=[batch.CfnComputeEnvironment.Ec2ConfigurationObjectProperty(
image_type="imageType",
# the properties below are optional
batch_image_status="batchImageStatus",
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",
overrides=[batch.CfnComputeEnvironment.LaunchTemplateSpecificationOverrideProperty(
launch_template_id="launchTemplateId",
launch_template_name="launchTemplateName",
target_instance_types=["targetInstanceTypes"],
userdata_type="userdataType",
version="version"
)],
userdata_type="userdataType",
version="version"
),
managed_instances_provider=batch.CfnComputeEnvironment.ManagedInstancesProviderProperty(
infrastructure_role_arn="infrastructureRoleArn",
instance_launch_template=batch.CfnComputeEnvironment.InstanceLaunchTemplateProperty(
ec2_instance_profile_arn="ec2InstanceProfileArn",
network_configuration=batch.CfnComputeEnvironment.ManagedInstancesNetworkConfigurationProperty(
security_groups=["securityGroups"],
subnets=["subnets"]
),
# the properties below are optional
capacity_option_type="capacityOptionType",
capacity_reservations=batch.CfnComputeEnvironment.CapacityReservationsProperty(
reservation_group_arn="reservationGroupArn",
reservation_preference="reservationPreference"
),
fips_enabled=False,
instance_metadata_tags_propagation=False,
instance_requirements=batch.CfnComputeEnvironment.InstanceRequirementsProperty(
allowed_instance_types=["allowedInstanceTypes"]
),
local_storage_configuration=batch.CfnComputeEnvironment.ManagedInstancesLocalStorageConfigurationProperty(
use_local_storage=False
),
monitoring="monitoring",
storage_configuration=batch.CfnComputeEnvironment.ManagedInstancesStorageConfigurationProperty(
storage_size_gi_b=123
)
),
# the properties below are optional
infrastructure_optimization=batch.CfnComputeEnvironment.InfrastructureOptimizationProperty(
scale_in_after=123
),
propagate_tags="propagateTags"
),
minv_cpus=123,
placement_group="placementGroup",
scaling_policy=batch.CfnComputeEnvironment.ComputeScalingPolicyProperty(
min_scale_down_delay_minutes=123
),
security_group_ids=["securityGroupIds"],
spot_iam_fleet_role="spotIamFleetRole",
subnets=["subnets"],
tags={
"tags_key": "tags"
},
update_to_latest_image_version=False
),
context="context",
ecs_settings=batch.CfnComputeEnvironment.EcsSettingsProperty(
container_insights="containerInsights"
),
eks_configuration=batch.CfnComputeEnvironment.EksConfigurationProperty(
eks_cluster_arn="eksClusterArn",
kubernetes_namespace="kubernetesNamespace",
# the properties below are optional
access_entry=batch.CfnComputeEnvironment.EksAccessEntryProperty(
desired_state="desiredState",
status="status"
)
),
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
)
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.batch.*;
CfnComputeEnvironment cfnComputeEnvironment = CfnComputeEnvironment.Builder.create(this, "MyCfnComputeEnvironment")
.type("type")
// the properties below are optional
.computeEnvironmentName("computeEnvironmentName")
.computeResources(ComputeResourcesProperty.builder()
.maxvCpus(123)
.type("type")
// the properties below are optional
.allocationStrategy("allocationStrategy")
.bidPercentage(123)
.capacityTags(Map.of(
"capacityTagsKey", "capacityTags"))
.desiredvCpus(123)
.ec2Configuration(List.of(Ec2ConfigurationObjectProperty.builder()
.imageType("imageType")
// the properties below are optional
.batchImageStatus("batchImageStatus")
.imageIdOverride("imageIdOverride")
.imageKubernetesVersion("imageKubernetesVersion")
.build()))
.ec2KeyPair("ec2KeyPair")
.imageId("imageId")
.instanceRole("instanceRole")
.instanceTypes(List.of("instanceTypes"))
.launchTemplate(LaunchTemplateSpecificationProperty.builder()
.launchTemplateId("launchTemplateId")
.launchTemplateName("launchTemplateName")
.overrides(List.of(LaunchTemplateSpecificationOverrideProperty.builder()
.launchTemplateId("launchTemplateId")
.launchTemplateName("launchTemplateName")
.targetInstanceTypes(List.of("targetInstanceTypes"))
.userdataType("userdataType")
.version("version")
.build()))
.userdataType("userdataType")
.version("version")
.build())
.managedInstancesProvider(ManagedInstancesProviderProperty.builder()
.infrastructureRoleArn("infrastructureRoleArn")
.instanceLaunchTemplate(InstanceLaunchTemplateProperty.builder()
.ec2InstanceProfileArn("ec2InstanceProfileArn")
.networkConfiguration(ManagedInstancesNetworkConfigurationProperty.builder()
.securityGroups(List.of("securityGroups"))
.subnets(List.of("subnets"))
.build())
// the properties below are optional
.capacityOptionType("capacityOptionType")
.capacityReservations(CapacityReservationsProperty.builder()
.reservationGroupArn("reservationGroupArn")
.reservationPreference("reservationPreference")
.build())
.fipsEnabled(false)
.instanceMetadataTagsPropagation(false)
.instanceRequirements(InstanceRequirementsProperty.builder()
.allowedInstanceTypes(List.of("allowedInstanceTypes"))
.build())
.localStorageConfiguration(ManagedInstancesLocalStorageConfigurationProperty.builder()
.useLocalStorage(false)
.build())
.monitoring("monitoring")
.storageConfiguration(ManagedInstancesStorageConfigurationProperty.builder()
.storageSizeGiB(123)
.build())
.build())
// the properties below are optional
.infrastructureOptimization(InfrastructureOptimizationProperty.builder()
.scaleInAfter(123)
.build())
.propagateTags("propagateTags")
.build())
.minvCpus(123)
.placementGroup("placementGroup")
.scalingPolicy(ComputeScalingPolicyProperty.builder()
.minScaleDownDelayMinutes(123)
.build())
.securityGroupIds(List.of("securityGroupIds"))
.spotIamFleetRole("spotIamFleetRole")
.subnets(List.of("subnets"))
.tags(Map.of(
"tagsKey", "tags"))
.updateToLatestImageVersion(false)
.build())
.context("context")
.ecsSettings(EcsSettingsProperty.builder()
.containerInsights("containerInsights")
.build())
.eksConfiguration(EksConfigurationProperty.builder()
.eksClusterArn("eksClusterArn")
.kubernetesNamespace("kubernetesNamespace")
// the properties below are optional
.accessEntry(EksAccessEntryProperty.builder()
.desiredState("desiredState")
.status("status")
.build())
.build())
.replaceComputeEnvironment(false)
.serviceRole("serviceRole")
.state("state")
.tags(Map.of(
"tagsKey", "tags"))
.unmanagedvCpus(123)
.updatePolicy(UpdatePolicyProperty.builder()
.jobExecutionTimeoutMinutes(123)
.terminateJobsOnUpdate(false)
.build())
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Batch;
var cfnComputeEnvironment = new CfnComputeEnvironment(this, "MyCfnComputeEnvironment", new CfnComputeEnvironmentProps {
Type = "type",
// the properties below are optional
ComputeEnvironmentName = "computeEnvironmentName",
ComputeResources = new ComputeResourcesProperty {
MaxvCpus = 123,
Type = "type",
// the properties below are optional
AllocationStrategy = "allocationStrategy",
BidPercentage = 123,
CapacityTags = new Dictionary<string, string> {
{ "capacityTagsKey", "capacityTags" }
},
DesiredvCpus = 123,
Ec2Configuration = new [] { new Ec2ConfigurationObjectProperty {
ImageType = "imageType",
// the properties below are optional
BatchImageStatus = "batchImageStatus",
ImageIdOverride = "imageIdOverride",
ImageKubernetesVersion = "imageKubernetesVersion"
} },
Ec2KeyPair = "ec2KeyPair",
ImageId = "imageId",
InstanceRole = "instanceRole",
InstanceTypes = new [] { "instanceTypes" },
LaunchTemplate = new LaunchTemplateSpecificationProperty {
LaunchTemplateId = "launchTemplateId",
LaunchTemplateName = "launchTemplateName",
Overrides = new [] { new LaunchTemplateSpecificationOverrideProperty {
LaunchTemplateId = "launchTemplateId",
LaunchTemplateName = "launchTemplateName",
TargetInstanceTypes = new [] { "targetInstanceTypes" },
UserdataType = "userdataType",
Version = "version"
} },
UserdataType = "userdataType",
Version = "version"
},
ManagedInstancesProvider = new ManagedInstancesProviderProperty {
InfrastructureRoleArn = "infrastructureRoleArn",
InstanceLaunchTemplate = new InstanceLaunchTemplateProperty {
Ec2InstanceProfileArn = "ec2InstanceProfileArn",
NetworkConfiguration = new ManagedInstancesNetworkConfigurationProperty {
SecurityGroups = new [] { "securityGroups" },
Subnets = new [] { "subnets" }
},
// the properties below are optional
CapacityOptionType = "capacityOptionType",
CapacityReservations = new CapacityReservationsProperty {
ReservationGroupArn = "reservationGroupArn",
ReservationPreference = "reservationPreference"
},
FipsEnabled = false,
InstanceMetadataTagsPropagation = false,
InstanceRequirements = new InstanceRequirementsProperty {
AllowedInstanceTypes = new [] { "allowedInstanceTypes" }
},
LocalStorageConfiguration = new ManagedInstancesLocalStorageConfigurationProperty {
UseLocalStorage = false
},
Monitoring = "monitoring",
StorageConfiguration = new ManagedInstancesStorageConfigurationProperty {
StorageSizeGiB = 123
}
},
// the properties below are optional
InfrastructureOptimization = new InfrastructureOptimizationProperty {
ScaleInAfter = 123
},
PropagateTags = "propagateTags"
},
MinvCpus = 123,
PlacementGroup = "placementGroup",
ScalingPolicy = new ComputeScalingPolicyProperty {
MinScaleDownDelayMinutes = 123
},
SecurityGroupIds = new [] { "securityGroupIds" },
SpotIamFleetRole = "spotIamFleetRole",
Subnets = new [] { "subnets" },
Tags = new Dictionary<string, string> {
{ "tagsKey", "tags" }
},
UpdateToLatestImageVersion = false
},
Context = "context",
EcsSettings = new EcsSettingsProperty {
ContainerInsights = "containerInsights"
},
EksConfiguration = new EksConfigurationProperty {
EksClusterArn = "eksClusterArn",
KubernetesNamespace = "kubernetesNamespace",
// the properties below are optional
AccessEntry = new EksAccessEntryProperty {
DesiredState = "desiredState",
Status = "status"
}
},
ReplaceComputeEnvironment = false,
ServiceRole = "serviceRole",
State = "state",
Tags = new Dictionary<string, string> {
{ "tagsKey", "tags" }
},
UnmanagedvCpus = 123,
UpdatePolicy = new UpdatePolicyProperty {
JobExecutionTimeoutMinutes = 123,
TerminateJobsOnUpdate = false
}
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
cfnComputeEnvironment := awscdk.Aws_batch.NewCfnComputeEnvironment(this, jsii.String("MyCfnComputeEnvironment"), &CfnComputeEnvironmentProps{
Type: jsii.String("type"),
// the properties below are optional
ComputeEnvironmentName: jsii.String("computeEnvironmentName"),
ComputeResources: &ComputeResourcesProperty{
MaxvCpus: jsii.Number(123),
Type: jsii.String("type"),
// the properties below are optional
AllocationStrategy: jsii.String("allocationStrategy"),
BidPercentage: jsii.Number(123),
CapacityTags: map[string]*string{
"capacityTagsKey": jsii.String("capacityTags"),
},
DesiredvCpus: jsii.Number(123),
Ec2Configuration: []interface{}{
&Ec2ConfigurationObjectProperty{
ImageType: jsii.String("imageType"),
// the properties below are optional
BatchImageStatus: jsii.String("batchImageStatus"),
ImageIdOverride: jsii.String("imageIdOverride"),
ImageKubernetesVersion: jsii.String("imageKubernetesVersion"),
},
},
Ec2KeyPair: jsii.String("ec2KeyPair"),
ImageId: jsii.String("imageId"),
InstanceRole: jsii.String("instanceRole"),
InstanceTypes: []*string{
jsii.String("instanceTypes"),
},
LaunchTemplate: &LaunchTemplateSpecificationProperty{
LaunchTemplateId: jsii.String("launchTemplateId"),
LaunchTemplateName: jsii.String("launchTemplateName"),
Overrides: []interface{}{
&LaunchTemplateSpecificationOverrideProperty{
LaunchTemplateId: jsii.String("launchTemplateId"),
LaunchTemplateName: jsii.String("launchTemplateName"),
TargetInstanceTypes: []*string{
jsii.String("targetInstanceTypes"),
},
UserdataType: jsii.String("userdataType"),
Version: jsii.String("version"),
},
},
UserdataType: jsii.String("userdataType"),
Version: jsii.String("version"),
},
ManagedInstancesProvider: &ManagedInstancesProviderProperty{
InfrastructureRoleArn: jsii.String("infrastructureRoleArn"),
InstanceLaunchTemplate: &InstanceLaunchTemplateProperty{
Ec2InstanceProfileArn: jsii.String("ec2InstanceProfileArn"),
NetworkConfiguration: &ManagedInstancesNetworkConfigurationProperty{
SecurityGroups: []*string{
jsii.String("securityGroups"),
},
Subnets: []*string{
jsii.String("subnets"),
},
},
// the properties below are optional
CapacityOptionType: jsii.String("capacityOptionType"),
CapacityReservations: &CapacityReservationsProperty{
ReservationGroupArn: jsii.String("reservationGroupArn"),
ReservationPreference: jsii.String("reservationPreference"),
},
FipsEnabled: jsii.Boolean(false),
InstanceMetadataTagsPropagation: jsii.Boolean(false),
InstanceRequirements: &InstanceRequirementsProperty{
AllowedInstanceTypes: []*string{
jsii.String("allowedInstanceTypes"),
},
},
LocalStorageConfiguration: &ManagedInstancesLocalStorageConfigurationProperty{
UseLocalStorage: jsii.Boolean(false),
},
Monitoring: jsii.String("monitoring"),
StorageConfiguration: &ManagedInstancesStorageConfigurationProperty{
StorageSizeGiB: jsii.Number(123),
},
},
// the properties below are optional
InfrastructureOptimization: &InfrastructureOptimizationProperty{
ScaleInAfter: jsii.Number(123),
},
PropagateTags: jsii.String("propagateTags"),
},
MinvCpus: jsii.Number(123),
PlacementGroup: jsii.String("placementGroup"),
ScalingPolicy: &ComputeScalingPolicyProperty{
MinScaleDownDelayMinutes: jsii.Number(123),
},
SecurityGroupIds: []*string{
jsii.String("securityGroupIds"),
},
SpotIamFleetRole: jsii.String("spotIamFleetRole"),
Subnets: []*string{
jsii.String("subnets"),
},
Tags: map[string]*string{
"tagsKey": jsii.String("tags"),
},
UpdateToLatestImageVersion: jsii.Boolean(false),
},
Context: jsii.String("context"),
EcsSettings: &EcsSettingsProperty{
ContainerInsights: jsii.String("containerInsights"),
},
EksConfiguration: &EksConfigurationProperty{
EksClusterArn: jsii.String("eksClusterArn"),
KubernetesNamespace: jsii.String("kubernetesNamespace"),
// the properties below are optional
AccessEntry: &EksAccessEntryProperty{
DesiredState: jsii.String("desiredState"),
Status: jsii.String("status"),
},
},
ReplaceComputeEnvironment: jsii.Boolean(false),
ServiceRole: jsii.String("serviceRole"),
State: jsii.String("state"),
Tags: map[string]*string{
"tagsKey": jsii.String("tags"),
},
UnmanagedvCpus: jsii.Number(123),
UpdatePolicy: &UpdatePolicyProperty{
JobExecutionTimeoutMinutes: jsii.Number(123),
TerminateJobsOnUpdate: jsii.Boolean(false),
},
})
Initializer
new CfnComputeEnvironment(scope: Construct, id: string, props: CfnComputeEnvironmentProps)
CfnComputeEnvironment(scope: Construct, id: str, props: CfnComputeEnvironmentProps)
new CfnComputeEnvironment(Construct scope, String id, CfnComputeEnvironmentProps props)
new CfnComputeEnvironment(Construct scope, string id, CfnComputeEnvironmentProps props)
NewCfnComputeEnvironment(Scope Construct, Id *string, Props CfnComputeEnvironmentProps)
Construct Props
computeEnvironmentNameoptionalstringcompute_environment_nameoptionalstrcomputeEnvironmentNameoptionalStringComputeEnvironmentNameoptionalstringComputeEnvironmentNameoptional*string#It can be up to 128 characters long. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).
computeResourcesoptionalIResolvable | CfnComputeEnvironment.ComputeResourcesPropertycompute_resourcesoptionaltyping.Union[IResolvable, ComputeResourcesProperty]computeResourcesoptionalIResolvableComputeResourcesoptionalIResolvableComputeResourcesoptionalinterface{}#This parameter is required for managed compute environments. For more information, see Compute Environments in the ** .
contextoptionalstringcontextoptionalstrcontextoptionalStringContextoptionalstringContextoptional*string#ecsSettingsoptionalIResolvable | CfnComputeEnvironment.EcsSettingsPropertyecs_settingsoptionaltyping.Union[IResolvable, EcsSettingsProperty]ecsSettingsoptionalIResolvableEcsSettingsoptionalIResolvableEcsSettingsoptionalinterface{}#eksConfigurationoptionalIResolvable | CfnComputeEnvironment.EksConfigurationPropertyeks_configurationoptionaltyping.Union[IResolvable, EksConfigurationProperty]eksConfigurationoptionalIResolvableEksConfigurationoptionalIResolvableEksConfigurationoptionalinterface{}#To create a compute environment that uses EKS resources, the caller must have permissions to call
eks:DescribeCluster.
replaceComputeEnvironmentoptionalboolean | IResolvablereplace_compute_environmentoptionaltyping.Union[bool, IResolvable]replaceComputeEnvironmentoptionalBooleanReplaceComputeEnvironmentoptionalboolReplaceComputeEnvironmentoptionalinterface{}= true#notes
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 , 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 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 .
ReplaceComputeEnvironment is not applicable for Fargate compute environments. Fargate compute environments are always updated without interruption.
The properties that can't be changed without replacing the compute environment are in the ComputeResources property type: AllocationStrategy , BidPercentage , Ec2Configuration , Ec2KeyPair , Ec2KeyPair , ImageId , InstanceRole , InstanceTypes , LaunchTemplate , MaxvCpus , MinvCpus , PlacementGroup , SecurityGroupIds , Subnets , Tags , Type , and UpdateToLatestImageVersion .
serviceRoleoptionalstring | IRoleRefservice_roleoptionaltyping.Union[str, IRoleRef]serviceRoleoptionalStringServiceRoleoptionalstringServiceRoleoptionalinterface{}#notes
For more information, see AWS Batch service IAM role in the AWS Batch User Guide .
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/ , specify /foo/bar as the role name. For more information, see Friendly names and paths in the IAM User Guide .
Depending on how you created your AWS Batch service role, its ARN might contain the
service-rolepath prefix. When you only specify the name of the service role, AWS Batch assumes that your ARN doesn't use theservice-rolepath prefix. Because of this, we recommend that you specify the full ARN of your service role when you create compute environments.
notes
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.
Compute environments in a
DISABLEDstate 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 the minvCpus value. However, the instance size doesn't change. For example, consider a c5.8xlarge instance with a minvCpus value of 4 and a desiredvCpus value of 36 . This instance doesn't scale down to a c5.large instance.
tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string#For more information, see Compute Environments in the AWS Batch User Guide .
unmanagedvCpusoptionalnumberunmanagedv_cpusoptionalint | floatunmanagedvCpusoptionalNumberUnmanagedvCpusoptionaldoubleUnmanagedvCpusoptional*float64#notes
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.
This parameter is only supported when the
typeparameter is set toUNMANAGED.
updatePolicyoptionalIResolvable | CfnComputeEnvironment.UpdatePolicyPropertyupdate_policyoptionaltyping.Union[IResolvable, UpdatePolicyProperty]updatePolicyoptionalIResolvableUpdatePolicyoptionalIResolvableUpdatePolicyoptionalinterface{}#For more information about infrastructure updates, see Updating compute environments in the AWS Batch User Guide .
Properties
attrComputeEnvironmentArnstringattr_compute_environment_arnstrattrComputeEnvironmentArnStringAttrComputeEnvironmentArnstringAttrComputeEnvironmentArn*stringrequired#attrEksConfigurationAccessEntryStatusstringattr_eks_configuration_access_entry_statusstrattrEksConfigurationAccessEntryStatusStringAttrEksConfigurationAccessEntryStatusstringAttrEksConfigurationAccessEntryStatus*stringrequired#CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringrequiredstatic#cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsrequired#cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*stringrequired#computeEnvironmentNamemay be undefinedstringcompute_environment_namemay be undefinedstrcomputeEnvironmentNamemay be undefinedStringComputeEnvironmentNamemay be undefinedstringComputeEnvironmentNamemay be undefined*string#computeEnvironmentRefComputeEnvironmentReferencecompute_environment_refComputeEnvironmentReferencecomputeEnvironmentRefComputeEnvironmentReferenceComputeEnvironmentRefComputeEnvironmentReferenceComputeEnvironmentRefComputeEnvironmentReferencerequired#computeResourcesmay be undefinedIResolvable | CfnComputeEnvironment.ComputeResourcesPropertycompute_resourcesmay be undefinedtyping.Union[IResolvable, ComputeResourcesProperty]computeResourcesmay be undefinedIResolvableComputeResourcesmay be undefinedIResolvableComputeResourcesmay be undefinedinterface{}#contextmay be undefinedstringcontextmay be undefinedstrcontextmay be undefinedStringContextmay be undefinedstringContextmay be undefined*string#creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#ecsSettingsmay be undefinedIResolvable | CfnComputeEnvironment.EcsSettingsPropertyecs_settingsmay be undefinedtyping.Union[IResolvable, EcsSettingsProperty]ecsSettingsmay be undefinedIResolvableEcsSettingsmay be undefinedIResolvableEcsSettingsmay be undefinedinterface{}#eksConfigurationmay be undefinedIResolvable | CfnComputeEnvironment.EksConfigurationPropertyeks_configurationmay be undefinedtyping.Union[IResolvable, EksConfigurationProperty]eksConfigurationmay be undefinedIResolvableEksConfigurationmay be undefinedIResolvableEksConfigurationmay be undefinedinterface{}#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).
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 }).
replaceComputeEnvironmentmay be undefinedboolean | IResolvablereplace_compute_environmentmay be undefinedtyping.Union[bool, IResolvable]replaceComputeEnvironmentmay be undefinedBooleanReplaceComputeEnvironmentmay be undefinedboolReplaceComputeEnvironmentmay be undefinedinterface{}#serviceRolemay be undefinedstringservice_rolemay be undefinedstrserviceRolemay be undefinedStringServiceRolemay be undefinedstringServiceRolemay be undefined*string#CfnElements must be defined within a stack scope (directly or indirectly).
statemay be undefinedstringstatemay be undefinedstrstatemay be undefinedStringStatemay be undefinedstringStatemay be undefined*string#tagsRawmay be undefined{ [key: string]: string }tags_rawmay be undefinedtyping.Mapping[str, str]tagsRawmay be undefinedMap<String, String>TagsRawmay be undefinedIDictionary<string, string>TagsRawmay be undefined*map[string]*string#unmanagedvCpusmay be undefinednumberunmanagedv_cpusmay be undefinedint | floatunmanagedvCpusmay be undefinedNumberUnmanagedvCpusmay be undefineddoubleUnmanagedvCpusmay be undefined*float64#updatePolicymay be undefinedIResolvable | CfnComputeEnvironment.UpdatePolicyPropertyupdate_policymay be undefinedtyping.Union[IResolvable, UpdatePolicyProperty]updatePolicymay be undefinedIResolvableUpdatePolicymay be undefinedIResolvableUpdatePolicymay be undefinedinterface{}#Methods
addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#1 parameter
Parameters
pathpathpathpathPath— The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.
addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.
addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#notes · 2 parameters
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,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"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
pathpathpathpathPath— - The path of the property, you can use dot notation to override values in complex types.valuevaluevaluevalueValue— - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#1 parameter
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#Syntactic sugar for addOverride("Properties.<...>", value).
2 parameters
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path of the property.valuevaluevaluevalueValue— The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.
1 parameter
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:
arnForComputeEnvironment(resource: IComputeEnvironmentRef): string@staticmethod def arn_for_compute_environment(resource: IComputeEnvironmentRef) -> strpublic static String arnForComputeEnvironment(IComputeEnvironmentRef resource)public static string ArnForComputeEnvironment(IComputeEnvironmentRef resource)func ArnForComputeEnvironment(Resource IComputeEnvironmentRef) *stringstatic#cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.
1 parameter
Parameters
attributeNameattribute_nameattributeNameattributeNameAttributeName— The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#1 parameter
Parameters
inspectorinspectorinspectorinspectorInspector— tree inspector to collect and process attributes.
isCfnComputeEnvironment(x: any): boolean@staticmethod def is_cfn_compute_environment(x: Any) -> boolpublic static Boolean isCfnComputeEnvironment(Object x)public static bool IsCfnComputeEnvironment(object x)func IsCfnComputeEnvironment(X interface{}) *boolstatic#isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.
returns
Returns: The construct as a stack element or undefined if it is not a stack element.
isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.
overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#1 parameter
Parameters
newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId— The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#2 parameters
Parameters
targettargettargettargetTarget— The dependency to replace.newTargetnew_targetnewTargetnewTargetNewTarget— The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#returns
Returns: a string representation of this resource
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.