Class ComputeResources.Builder
java.lang.Object
software.amazon.awscdk.services.batch.ComputeResources.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<ComputeResources>
- Enclosing interface:
ComputeResources
@Stability(Experimental)
public static final class ComputeResources.Builder
extends Object
implements software.amazon.jsii.Builder<ComputeResources>
A builder for
ComputeResources
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallocationStrategy
(AllocationStrategy allocationStrategy) Sets the value ofComputeResources.getAllocationStrategy()
bidPercentage
(Number bidPercentage) Sets the value ofComputeResources.getBidPercentage()
build()
Builds the configured instance.computeResourcesTags
(Map<String, String> computeResourcesTags) Sets the value ofComputeResources.getComputeResourcesTags()
desiredvCpus
(Number desiredvCpus) Sets the value ofComputeResources.getDesiredvCpus()
ec2KeyPair
(String ec2KeyPair) Sets the value ofComputeResources.getEc2KeyPair()
image
(IMachineImage image) Sets the value ofComputeResources.getImage()
instanceRole
(String instanceRole) Sets the value ofComputeResources.getInstanceRole()
instanceTypes
(List<? extends InstanceType> instanceTypes) Sets the value ofComputeResources.getInstanceTypes()
launchTemplate
(LaunchTemplateSpecification launchTemplate) Sets the value ofComputeResources.getLaunchTemplate()
Sets the value ofComputeResources.getMaxvCpus()
Sets the value ofComputeResources.getMinvCpus()
placementGroup
(String placementGroup) Sets the value ofComputeResources.getPlacementGroup()
securityGroups
(List<? extends ISecurityGroup> securityGroups) Sets the value ofComputeResources.getSecurityGroups()
spotFleetRole
(IRole spotFleetRole) Sets the value ofComputeResources.getSpotFleetRole()
type
(ComputeResourceType type) Sets the value ofComputeResources.getType()
Sets the value ofComputeResources.getVpc()
vpcSubnets
(SubnetSelection vpcSubnets) Sets the value ofComputeResources.getVpcSubnets()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
vpc
Sets the value ofComputeResources.getVpc()
- Parameters:
vpc
- The VPC network that all compute resources will be connected to. This parameter is required.- Returns:
this
-
allocationStrategy
@Stability(Experimental) public ComputeResources.Builder allocationStrategy(AllocationStrategy allocationStrategy) Sets the value ofComputeResources.getAllocationStrategy()
- Parameters:
allocationStrategy
- The allocation strategy to use for the compute resource in case not enough instances of the best fitting instance type can be allocated. This could be due to availability of the instance type in the region or Amazon EC2 service limits. If this is not specified, the default for the EC2 ComputeResourceType is BEST_FIT, which will use only the best fitting instance type, waiting for additional capacity if it's not available. 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 will select an additional instance type that is large enough to meet the requirements of the jobs in the queue, with a preference for an instance type with a lower cost. The default value for the SPOT instance type is SPOT_CAPACITY_OPTIMIZED, which is only available for for this type of compute resources and will select an additional instance type that is large enough to meet the requirements of the jobs in the queue, with a preference for an instance type that is less likely to be interrupted.- Returns:
this
-
bidPercentage
Sets the value ofComputeResources.getBidPercentage()
- Parameters:
bidPercentage
- This property will be ignored if you set the environment type to ON_DEMAND. The maximum percentage that a Spot Instance price can be when compared with the On-Demand price for that instance type before instances are launched. For example, if your maximum percentage is 20%, then the Spot price must be below 20% of the current On-Demand price for that EC2 instance. You always pay the lowest (market) price and never more than your maximum percentage. If you leave this field empty, the default value is 100% of the On-Demand price.- Returns:
this
-
computeResourcesTags
@Stability(Experimental) public ComputeResources.Builder computeResourcesTags(Map<String, String> computeResourcesTags) Sets the value ofComputeResources.getComputeResourcesTags()
- Parameters:
computeResourcesTags
- Key-value pair tags to be applied to resources that are launched in the compute environment. For AWS Batch, these take the form of "String1": "String2", where String1 is the tag key and String2 is the tag value—for example, { "Name": "AWS Batch Instance - C4OnDemand" }.- Returns:
this
-
desiredvCpus
Sets the value ofComputeResources.getDesiredvCpus()
- Parameters:
desiredvCpus
- The desired number of EC2 vCPUS in the compute environment.- Returns:
this
-
ec2KeyPair
Sets the value ofComputeResources.getEc2KeyPair()
- Parameters:
ec2KeyPair
- The EC2 key pair that is used for instances launched in the compute environment. If no key is defined, then SSH access is not allowed to provisioned compute resources.- Returns:
this
-
image
Sets the value ofComputeResources.getImage()
- Parameters:
image
- The Amazon Machine Image (AMI) ID used for instances launched in the compute environment.- Returns:
this
-
instanceRole
Sets the value ofComputeResources.getInstanceRole()
- Parameters:
instanceRole
- The Amazon ECS instance profile applied to Amazon EC2 instances in a compute environment. You can specify the short name or full Amazon Resource Name (ARN) of an instance profile. For example, ecsInstanceRole or arn:aws:iam::<aws_account_id>:instance-profile/ecsInstanceRole . For more information, see Amazon ECS Instance Role in the AWS Batch User Guide.- Returns:
this
-
instanceTypes
@Stability(Experimental) public ComputeResources.Builder instanceTypes(List<? extends InstanceType> instanceTypes) Sets the value ofComputeResources.getInstanceTypes()
- Parameters:
instanceTypes
- The types of EC2 instances that may be launched in the compute environment. You can specify instance families to launch any instance type within those families (for example, c4 or p3), or you can specify specific sizes within a family (such as c4.8xlarge). You can also choose optimal to pick instance types (from the C, M, and R instance families) on the fly that match the demand of your job queues.- Returns:
this
-
launchTemplate
@Stability(Experimental) public ComputeResources.Builder launchTemplate(LaunchTemplateSpecification launchTemplate) Sets the value ofComputeResources.getLaunchTemplate()
- Parameters:
launchTemplate
- An optional launch template to associate with your compute resources. For more information, see README file.- Returns:
this
-
maxvCpus
Sets the value ofComputeResources.getMaxvCpus()
- Parameters:
maxvCpus
- The maximum number of EC2 vCPUs that an environment can reach. Each vCPU is equivalent to 1,024 CPU shares. You must specify at least one vCPU.- Returns:
this
-
minvCpus
Sets the value ofComputeResources.getMinvCpus()
- Parameters:
minvCpus
- The minimum number of EC2 vCPUs that an environment should maintain (even if the compute environment state is DISABLED). Each vCPU is equivalent to 1,024 CPU shares. By keeping this set to 0 you will not have instance time wasted when there is no work to be run. If you set this above zero you will maintain that number of vCPUs at all times.- Returns:
this
-
placementGroup
Sets the value ofComputeResources.getPlacementGroup()
- Parameters:
placementGroup
- The Amazon EC2 placement group to associate with your compute resources.- Returns:
this
-
securityGroups
@Stability(Experimental) public ComputeResources.Builder securityGroups(List<? extends ISecurityGroup> securityGroups) Sets the value ofComputeResources.getSecurityGroups()
- Parameters:
securityGroups
- The EC2 security group(s) associated with instances launched in the compute environment.- Returns:
this
-
spotFleetRole
Sets the value ofComputeResources.getSpotFleetRole()
- Parameters:
spotFleetRole
- This property will be ignored if you set the environment type to ON_DEMAND. The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a SPOT compute environment. For more information, see Amazon EC2 Spot Fleet Role in the AWS Batch User Guide.- Returns:
this
-
type
Sets the value ofComputeResources.getType()
- Parameters:
type
- The type of compute environment: ON_DEMAND, SPOT, FARGATE, or FARGATE_SPOT.- Returns:
this
-
vpcSubnets
Sets the value ofComputeResources.getVpcSubnets()
- Parameters:
vpcSubnets
- The VPC subnets into which the compute resources are launched.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<ComputeResources>
- Returns:
- a new instance of
ComputeResources
- Throws:
NullPointerException
- if any required attribute was not provided
-