Class: AWSCDK::Autoscaling::LaunchTemplateOverrides

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
autoscaling/launch_template_overrides.rb

Overview

LaunchTemplateOverrides is a subproperty of LaunchTemplate that describes an override for a launch template.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance_requirements: nil, instance_type: nil, launch_template: nil, weighted_capacity: nil) ⇒ LaunchTemplateOverrides

Returns a new instance of LaunchTemplateOverrides.

Parameters:

  • instance_requirements (AWSCDK::Autoscaling::CfnAutoScalingGroup::InstanceRequirementsProperty, nil) (defaults to: nil)

    The instance requirements.

  • instance_type (AWSCDK::EC2::InstanceType, nil) (defaults to: nil)

    The instance type, such as m3.xlarge. You must use an instance type that is supported in your requested Region and Availability Zones.

  • launch_template (AWSCDK::EC2::ILaunchTemplate, nil) (defaults to: nil)

    Provides the launch template to be used when launching the instance type.

  • weighted_capacity (Numeric, nil) (defaults to: nil)

    The number of capacity units provided by the specified instance type in terms of virtual CPUs, memory, storage, throughput, or other relative performance characteristic.



11
12
13
14
15
16
17
18
19
20
# File 'autoscaling/launch_template_overrides.rb', line 11

def initialize(instance_requirements: nil, instance_type: nil, launch_template: nil, weighted_capacity: nil)
  @instance_requirements = instance_requirements.is_a?(Hash) ? ::AWSCDK::Autoscaling::CfnAutoScalingGroup::InstanceRequirementsProperty.new(**instance_requirements.transform_keys(&:to_sym)) : instance_requirements
  Jsii::Type.check_type(@instance_requirements, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuQ2ZuQXV0b1NjYWxpbmdHcm91cC5JbnN0YW5jZVJlcXVpcmVtZW50c1Byb3BlcnR5In0=")), "instanceRequirements") unless @instance_requirements.nil?
  @instance_type = instance_type
  Jsii::Type.check_type(@instance_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluc3RhbmNlVHlwZSJ9")), "instanceType") unless @instance_type.nil?
  @launch_template = launch_template
  Jsii::Type.check_type(@launch_template, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklMYXVuY2hUZW1wbGF0ZSJ9")), "launchTemplate") unless @launch_template.nil?
  @weighted_capacity = weighted_capacity
  Jsii::Type.check_type(@weighted_capacity, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "weightedCapacity") unless @weighted_capacity.nil?
end

Instance Attribute Details

#instance_requirementsAWSCDK::Autoscaling::CfnAutoScalingGroup::InstanceRequirementsProperty? (readonly)

Note:

Default: - Do not override instance type

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.

You must specify one of instanceRequirements or instanceType.



36
37
38
# File 'autoscaling/launch_template_overrides.rb', line 36

def instance_requirements
  @instance_requirements
end

#instance_typeAWSCDK::EC2::InstanceType? (readonly)

Note:

Default: - Do not override instance type

The instance type, such as m3.xlarge. You must use an instance type that is supported in your requested Region and Availability Zones.

You must specify one of instanceRequirements or instanceType.

Returns:



43
44
45
# File 'autoscaling/launch_template_overrides.rb', line 43

def instance_type
  @instance_type
end

#launch_templateAWSCDK::EC2::ILaunchTemplate? (readonly)

Note:

Default: - Do not override launch template

Provides the launch template to be used when launching the instance type.

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 defined for your mixed instances policy.



52
53
54
# File 'autoscaling/launch_template_overrides.rb', line 52

def launch_template
  @launch_template
end

#weighted_capacityNumeric? (readonly)

Note:

Default: - Do not provide weight

The number of capacity units provided by the specified instance type in terms of virtual CPUs, memory, storage, throughput, or other relative performance characteristic.

When a Spot or On-Demand Instance is provisioned, the capacity units count toward the desired capacity. Amazon EC2 Auto Scaling provisions instances until the desired capacity is totally fulfilled, even if this results in an overage. Value must be in the range of 1 to 999.

For example, If there are 2 units remaining to fulfill capacity, and Amazon EC2 Auto Scaling can only provision an instance with a WeightedCapacity of 5 units, the instance is provisioned, and the desired capacity is exceeded by 3 units.



66
67
68
# File 'autoscaling/launch_template_overrides.rb', line 66

def weighted_capacity
  @weighted_capacity
end

Class Method Details

.jsii_propertiesObject



68
69
70
71
72
73
74
75
# File 'autoscaling/launch_template_overrides.rb', line 68

def self.jsii_properties
  {
    :instance_requirements => "instanceRequirements",
    :instance_type => "instanceType",
    :launch_template => "launchTemplate",
    :weighted_capacity => "weightedCapacity",
  }
end

Instance Method Details

#to_jsiiObject



77
78
79
80
81
82
83
84
85
86
# File 'autoscaling/launch_template_overrides.rb', line 77

def to_jsii
  result = {}
  result.merge!({
    "instanceRequirements" => @instance_requirements,
    "instanceType" => @instance_type,
    "launchTemplate" => @launch_template,
    "weightedCapacity" => @weighted_capacity,
  })
  result.compact
end