All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.autoscaling.model.LaunchTemplateOverrides Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Auto Scaling module holds the client classes that are used for communicating with Auto Scaling Service

There is a newer version: 2.29.15
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.autoscaling.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Use this structure to let Amazon EC2 Auto Scaling do the following when the Auto Scaling group has a mixed instances * policy: *

*
    *
  • *

    * Override the instance type that is specified in the launch template. *

    *
  • *
  • *

    * Use multiple instance types. *

    *
  • *
*

* Specify the instance types that you want, or define your instance requirements instead and let Amazon EC2 Auto * Scaling provision the available instance types that meet your requirements. This can provide Amazon EC2 Auto Scaling * with a larger selection of instance types to choose from when fulfilling Spot and On-Demand capacities. You can view * which instance types are matched before you apply the instance requirements to your Auto Scaling group. *

*

* After you define your instance requirements, you don't have to keep updating these settings to get new EC2 instance * types automatically. Amazon EC2 Auto Scaling uses the instance requirements of the Auto Scaling group to determine * whether a new EC2 instance type can be used. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LaunchTemplateOverrides implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField INSTANCE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("InstanceType").getter(getter(LaunchTemplateOverrides::instanceType)) .setter(setter(Builder::instanceType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceType").build()).build(); private static final SdkField WEIGHTED_CAPACITY_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("WeightedCapacity").getter(getter(LaunchTemplateOverrides::weightedCapacity)) .setter(setter(Builder::weightedCapacity)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WeightedCapacity").build()).build(); private static final SdkField LAUNCH_TEMPLATE_SPECIFICATION_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("LaunchTemplateSpecification") .getter(getter(LaunchTemplateOverrides::launchTemplateSpecification)) .setter(setter(Builder::launchTemplateSpecification)) .constructor(LaunchTemplateSpecification::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LaunchTemplateSpecification") .build()).build(); private static final SdkField INSTANCE_REQUIREMENTS_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("InstanceRequirements") .getter(getter(LaunchTemplateOverrides::instanceRequirements)).setter(setter(Builder::instanceRequirements)) .constructor(InstanceRequirements::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceRequirements").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INSTANCE_TYPE_FIELD, WEIGHTED_CAPACITY_FIELD, LAUNCH_TEMPLATE_SPECIFICATION_FIELD, INSTANCE_REQUIREMENTS_FIELD)); private static final long serialVersionUID = 1L; private final String instanceType; private final String weightedCapacity; private final LaunchTemplateSpecification launchTemplateSpecification; private final InstanceRequirements instanceRequirements; private LaunchTemplateOverrides(BuilderImpl builder) { this.instanceType = builder.instanceType; this.weightedCapacity = builder.weightedCapacity; this.launchTemplateSpecification = builder.launchTemplateSpecification; this.instanceRequirements = builder.instanceRequirements; } /** *

* The instance type, such as m3.xlarge. You must specify an instance type that is supported in your * requested Region and Availability Zones. For more information, see Instance types in the * Amazon EC2 User Guide for Linux Instances. *

*

* You can specify up to 40 instance types per Auto Scaling group. *

* * @return The instance type, such as m3.xlarge. You must specify an instance type that is supported in * your requested Region and Availability Zones. For more information, see Instance types in the * Amazon EC2 User Guide for Linux Instances.

*

* You can specify up to 40 instance types per Auto Scaling group. */ public final String instanceType() { return instanceType; } /** *

* If you provide a list of instance types to use, you can specify the number of capacity units provided by each * instance type in terms of virtual CPUs, memory, storage, throughput, or other relative performance * characteristic. When a Spot or On-Demand Instance is launched, the capacity units count toward the desired * capacity. Amazon EC2 Auto Scaling launches instances until the desired capacity is totally fulfilled, even if * this results in an overage. For example, if there are two units remaining to fulfill capacity, and Amazon EC2 * Auto Scaling can only launch an instance with a WeightedCapacity of five units, the instance is * launched, and the desired capacity is exceeded by three units. For more information, see Configure an Auto Scaling group to use instance weights in the Amazon EC2 Auto Scaling User Guide. * Value must be in the range of 1–999. *

*

* If you specify a value for WeightedCapacity for one instance type, you must specify a value for * WeightedCapacity for all of them. *

* *

* Every Auto Scaling group has three size parameters (DesiredCapacity, MaxSize, and * MinSize). Usually, you set these sizes based on a specific number of instances. However, if you * configure a mixed instances policy that defines weights for the instance types, you must specify these sizes with * the same units that you use for weighting instances. *

*
* * @return If you provide a list of instance types to use, you can specify the number of capacity units provided by * each instance type in terms of virtual CPUs, memory, storage, throughput, or other relative performance * characteristic. When a Spot or On-Demand Instance is launched, the capacity units count toward the * desired capacity. Amazon EC2 Auto Scaling launches instances until the desired capacity is totally * fulfilled, even if this results in an overage. For example, if there are two units remaining to fulfill * capacity, and Amazon EC2 Auto Scaling can only launch an instance with a WeightedCapacity of * five units, the instance is launched, and the desired capacity is exceeded by three units. For more * information, see Configure an Auto Scaling group to use instance weights in the Amazon EC2 Auto Scaling User * Guide. Value must be in the range of 1–999.

*

* If you specify a value for WeightedCapacity for one instance type, you must specify a value * for WeightedCapacity for all of them. *

* *

* Every Auto Scaling group has three size parameters (DesiredCapacity, MaxSize, * and MinSize). Usually, you set these sizes based on a specific number of instances. However, * if you configure a mixed instances policy that defines weights for the instance types, you must specify * these sizes with the same units that you use for weighting instances. *

*/ public final String weightedCapacity() { return weightedCapacity; } /** *

* Provides a launch template for the specified instance type or set of instance requirements. For example, some * instance types might require a launch template with a different AMI. If not provided, Amazon EC2 Auto Scaling * uses the launch template that's specified in the LaunchTemplate definition. For more information, * see Specifying a different launch template for an instance type in the Amazon EC2 Auto Scaling User * Guide. *

*

* You can specify up to 20 launch templates per Auto Scaling group. The launch templates specified in the overrides * and in the LaunchTemplate definition count towards this limit. *

* * @return Provides a launch template for the specified instance type or set of instance requirements. For example, * some instance types might require a launch template with a different AMI. If not provided, Amazon EC2 * Auto Scaling uses the launch template that's specified in the LaunchTemplate definition. For * more information, see Specifying a different launch template for an instance type in the Amazon EC2 Auto Scaling User * Guide.

*

* You can specify up to 20 launch templates per Auto Scaling group. The launch templates specified in the * overrides and in the LaunchTemplate definition count towards this limit. */ public final LaunchTemplateSpecification launchTemplateSpecification() { return launchTemplateSpecification; } /** *

* The instance requirements. Amazon EC2 Auto Scaling uses your specified requirements to identify instance types. * Then, it uses your On-Demand and Spot allocation strategies to launch instances from these instance types. *

*

* You can specify up to four separate sets of instance requirements per Auto Scaling group. This is useful for * provisioning instances from different Amazon Machine Images (AMIs) in the same Auto Scaling group. To do this, * create the AMIs and create a new launch template for each AMI. Then, create a compatible set of instance * requirements for each launch template. *

* *

* If you specify InstanceRequirements, you can't specify InstanceType. *

*
* * @return The instance requirements. Amazon EC2 Auto Scaling uses your specified requirements to identify instance * types. Then, it uses your On-Demand and Spot allocation strategies to launch instances from these * instance types.

*

* You can specify up to four separate sets of instance requirements per Auto Scaling group. This is useful * for provisioning instances from different Amazon Machine Images (AMIs) in the same Auto Scaling group. To * do this, create the AMIs and create a new launch template for each AMI. Then, create a compatible set of * instance requirements for each launch template. *

* *

* If you specify InstanceRequirements, you can't specify InstanceType. *

*/ public final InstanceRequirements instanceRequirements() { return instanceRequirements; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(instanceType()); hashCode = 31 * hashCode + Objects.hashCode(weightedCapacity()); hashCode = 31 * hashCode + Objects.hashCode(launchTemplateSpecification()); hashCode = 31 * hashCode + Objects.hashCode(instanceRequirements()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof LaunchTemplateOverrides)) { return false; } LaunchTemplateOverrides other = (LaunchTemplateOverrides) obj; return Objects.equals(instanceType(), other.instanceType()) && Objects.equals(weightedCapacity(), other.weightedCapacity()) && Objects.equals(launchTemplateSpecification(), other.launchTemplateSpecification()) && Objects.equals(instanceRequirements(), other.instanceRequirements()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("LaunchTemplateOverrides").add("InstanceType", instanceType()) .add("WeightedCapacity", weightedCapacity()).add("LaunchTemplateSpecification", launchTemplateSpecification()) .add("InstanceRequirements", instanceRequirements()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "InstanceType": return Optional.ofNullable(clazz.cast(instanceType())); case "WeightedCapacity": return Optional.ofNullable(clazz.cast(weightedCapacity())); case "LaunchTemplateSpecification": return Optional.ofNullable(clazz.cast(launchTemplateSpecification())); case "InstanceRequirements": return Optional.ofNullable(clazz.cast(instanceRequirements())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((LaunchTemplateOverrides) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The instance type, such as m3.xlarge. You must specify an instance type that is supported in * your requested Region and Availability Zones. For more information, see Instance types in the * Amazon EC2 User Guide for Linux Instances. *

*

* You can specify up to 40 instance types per Auto Scaling group. *

* * @param instanceType * The instance type, such as m3.xlarge. You must specify an instance type that is supported * in your requested Region and Availability Zones. For more information, see Instance types in * the Amazon EC2 User Guide for Linux Instances.

*

* You can specify up to 40 instance types per Auto Scaling group. * @return Returns a reference to this object so that method calls can be chained together. */ Builder instanceType(String instanceType); /** *

* If you provide a list of instance types to use, you can specify the number of capacity units provided by each * instance type in terms of virtual CPUs, memory, storage, throughput, or other relative performance * characteristic. When a Spot or On-Demand Instance is launched, the capacity units count toward the desired * capacity. Amazon EC2 Auto Scaling launches instances until the desired capacity is totally fulfilled, even if * this results in an overage. For example, if there are two units remaining to fulfill capacity, and Amazon EC2 * Auto Scaling can only launch an instance with a WeightedCapacity of five units, the instance is * launched, and the desired capacity is exceeded by three units. For more information, see Configure an Auto Scaling group to use instance weights in the Amazon EC2 Auto Scaling User * Guide. Value must be in the range of 1–999. *

*

* If you specify a value for WeightedCapacity for one instance type, you must specify a value for * WeightedCapacity for all of them. *

* *

* Every Auto Scaling group has three size parameters (DesiredCapacity, MaxSize, and * MinSize). Usually, you set these sizes based on a specific number of instances. However, if you * configure a mixed instances policy that defines weights for the instance types, you must specify these sizes * with the same units that you use for weighting instances. *

*
* * @param weightedCapacity * If you provide a list of instance types to use, you can specify the number of capacity units provided * by each instance type in terms of virtual CPUs, memory, storage, throughput, or other relative * performance characteristic. When a Spot or On-Demand Instance is launched, the capacity units count * toward the desired capacity. Amazon EC2 Auto Scaling launches instances until the desired capacity is * totally fulfilled, even if this results in an overage. For example, if there are two units remaining * to fulfill capacity, and Amazon EC2 Auto Scaling can only launch an instance with a * WeightedCapacity of five units, the instance is launched, and the desired capacity is * exceeded by three units. For more information, see Configure an Auto Scaling group to use instance weights in the Amazon EC2 Auto Scaling User * Guide. Value must be in the range of 1–999.

*

* If you specify a value for WeightedCapacity for one instance type, you must specify a * value for WeightedCapacity for all of them. *

* *

* Every Auto Scaling group has three size parameters (DesiredCapacity, MaxSize * , and MinSize). Usually, you set these sizes based on a specific number of instances. * However, if you configure a mixed instances policy that defines weights for the instance types, you * must specify these sizes with the same units that you use for weighting instances. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder weightedCapacity(String weightedCapacity); /** *

* Provides a launch template for the specified instance type or set of instance requirements. For example, some * instance types might require a launch template with a different AMI. If not provided, Amazon EC2 Auto Scaling * uses the launch template that's specified in the LaunchTemplate definition. For more * information, see Specifying a different launch template for an instance type in the Amazon EC2 Auto Scaling User * Guide. *

*

* You can specify up to 20 launch templates per Auto Scaling group. The launch templates specified in the * overrides and in the LaunchTemplate definition count towards this limit. *

* * @param launchTemplateSpecification * Provides a launch template for the specified instance type or set of instance requirements. For * example, some instance types might require a launch template with a different AMI. If not provided, * Amazon EC2 Auto Scaling uses the launch template that's specified in the LaunchTemplate * definition. For more information, see Specifying a different launch template for an instance type in the Amazon EC2 Auto Scaling * User Guide.

*

* You can specify up to 20 launch templates per Auto Scaling group. The launch templates specified in * the overrides and in the LaunchTemplate definition count towards this limit. * @return Returns a reference to this object so that method calls can be chained together. */ Builder launchTemplateSpecification(LaunchTemplateSpecification launchTemplateSpecification); /** *

* Provides a launch template for the specified instance type or set of instance requirements. For example, some * instance types might require a launch template with a different AMI. If not provided, Amazon EC2 Auto Scaling * uses the launch template that's specified in the LaunchTemplate definition. For more * information, see Specifying a different launch template for an instance type in the Amazon EC2 Auto Scaling User * Guide. *

*

* You can specify up to 20 launch templates per Auto Scaling group. The launch templates specified in the * overrides and in the LaunchTemplate definition count towards this limit. *

* This is a convenience method that creates an instance of the {@link LaunchTemplateSpecification.Builder} * avoiding the need to create one manually via {@link LaunchTemplateSpecification#builder()}. * *

* When the {@link Consumer} completes, {@link LaunchTemplateSpecification.Builder#build()} is called * immediately and its result is passed to {@link #launchTemplateSpecification(LaunchTemplateSpecification)}. * * @param launchTemplateSpecification * a consumer that will call methods on {@link LaunchTemplateSpecification.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #launchTemplateSpecification(LaunchTemplateSpecification) */ default Builder launchTemplateSpecification(Consumer launchTemplateSpecification) { return launchTemplateSpecification(LaunchTemplateSpecification.builder().applyMutation(launchTemplateSpecification) .build()); } /** *

* The instance requirements. Amazon EC2 Auto Scaling uses your specified requirements to identify instance * types. Then, it uses your On-Demand and Spot allocation strategies to launch instances from these instance * types. *

*

* You can specify up to four separate sets of instance requirements per Auto Scaling group. This is useful for * provisioning instances from different Amazon Machine Images (AMIs) in the same Auto Scaling group. To do * this, create the AMIs and create a new launch template for each AMI. Then, create a compatible set of * instance requirements for each launch template. *

* *

* If you specify InstanceRequirements, you can't specify InstanceType. *

*
* * @param instanceRequirements * The instance requirements. Amazon EC2 Auto Scaling uses your specified requirements to identify * instance types. Then, it uses your On-Demand and Spot allocation strategies to launch instances from * these instance types.

*

* You can specify up to four separate sets of instance requirements per Auto Scaling group. This is * useful for provisioning instances from different Amazon Machine Images (AMIs) in the same Auto Scaling * group. To do this, create the AMIs and create a new launch template for each AMI. Then, create a * compatible set of instance requirements for each launch template. *

* *

* If you specify InstanceRequirements, you can't specify InstanceType. *

* @return Returns a reference to this object so that method calls can be chained together. */ Builder instanceRequirements(InstanceRequirements instanceRequirements); /** *

* The instance requirements. Amazon EC2 Auto Scaling uses your specified requirements to identify instance * types. Then, it uses your On-Demand and Spot allocation strategies to launch instances from these instance * types. *

*

* You can specify up to four separate sets of instance requirements per Auto Scaling group. This is useful for * provisioning instances from different Amazon Machine Images (AMIs) in the same Auto Scaling group. To do * this, create the AMIs and create a new launch template for each AMI. Then, create a compatible set of * instance requirements for each launch template. *

* *

* If you specify InstanceRequirements, you can't specify InstanceType. *

*
This is a convenience method that creates an instance of the {@link InstanceRequirements.Builder} * avoiding the need to create one manually via {@link InstanceRequirements#builder()}. * *

* When the {@link Consumer} completes, {@link InstanceRequirements.Builder#build()} is called immediately and * its result is passed to {@link #instanceRequirements(InstanceRequirements)}. * * @param instanceRequirements * a consumer that will call methods on {@link InstanceRequirements.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #instanceRequirements(InstanceRequirements) */ default Builder instanceRequirements(Consumer instanceRequirements) { return instanceRequirements(InstanceRequirements.builder().applyMutation(instanceRequirements).build()); } } static final class BuilderImpl implements Builder { private String instanceType; private String weightedCapacity; private LaunchTemplateSpecification launchTemplateSpecification; private InstanceRequirements instanceRequirements; private BuilderImpl() { } private BuilderImpl(LaunchTemplateOverrides model) { instanceType(model.instanceType); weightedCapacity(model.weightedCapacity); launchTemplateSpecification(model.launchTemplateSpecification); instanceRequirements(model.instanceRequirements); } public final String getInstanceType() { return instanceType; } public final void setInstanceType(String instanceType) { this.instanceType = instanceType; } @Override public final Builder instanceType(String instanceType) { this.instanceType = instanceType; return this; } public final String getWeightedCapacity() { return weightedCapacity; } public final void setWeightedCapacity(String weightedCapacity) { this.weightedCapacity = weightedCapacity; } @Override public final Builder weightedCapacity(String weightedCapacity) { this.weightedCapacity = weightedCapacity; return this; } public final LaunchTemplateSpecification.Builder getLaunchTemplateSpecification() { return launchTemplateSpecification != null ? launchTemplateSpecification.toBuilder() : null; } public final void setLaunchTemplateSpecification(LaunchTemplateSpecification.BuilderImpl launchTemplateSpecification) { this.launchTemplateSpecification = launchTemplateSpecification != null ? launchTemplateSpecification.build() : null; } @Override public final Builder launchTemplateSpecification(LaunchTemplateSpecification launchTemplateSpecification) { this.launchTemplateSpecification = launchTemplateSpecification; return this; } public final InstanceRequirements.Builder getInstanceRequirements() { return instanceRequirements != null ? instanceRequirements.toBuilder() : null; } public final void setInstanceRequirements(InstanceRequirements.BuilderImpl instanceRequirements) { this.instanceRequirements = instanceRequirements != null ? instanceRequirements.build() : null; } @Override public final Builder instanceRequirements(InstanceRequirements instanceRequirements) { this.instanceRequirements = instanceRequirements; return this; } @Override public LaunchTemplateOverrides build() { return new LaunchTemplateOverrides(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy