Skip to content
v2.277.0

LaunchTemplateOverrides Struct ​

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

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_autoscaling as autoscaling } from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';

declare const instanceType: ec2.InstanceType;
declare const launchTemplate: ec2.LaunchTemplate;
const launchTemplateOverrides: autoscaling.LaunchTemplateOverrides = {
  instanceRequirements: {
    memoryMiB: {
      max: 123,
      min: 123,
    },
    vCpuCount: {
      max: 123,
      min: 123,
    },

    // the properties below are optional
    acceleratorCount: {
      max: 123,
      min: 123,
    },
    acceleratorManufacturers: ['acceleratorManufacturers'],
    acceleratorNames: ['acceleratorNames'],
    acceleratorTotalMemoryMiB: {
      max: 123,
      min: 123,
    },
    acceleratorTypes: ['acceleratorTypes'],
    allowedInstanceTypes: ['allowedInstanceTypes'],
    bareMetal: 'bareMetal',
    baselineEbsBandwidthMbps: {
      max: 123,
      min: 123,
    },
    baselinePerformanceFactors: {
      cpu: {
        references: [{
          instanceFamily: 'instanceFamily',
        }],
      },
    },
    burstablePerformance: 'burstablePerformance',
    cpuManufacturers: ['cpuManufacturers'],
    excludedInstanceTypes: ['excludedInstanceTypes'],
    instanceGenerations: ['instanceGenerations'],
    localStorage: 'localStorage',
    localStorageTypes: ['localStorageTypes'],
    maxSpotPriceAsPercentageOfOptimalOnDemandPrice: 123,
    memoryGiBPerVCpu: {
      max: 123,
      min: 123,
    },
    networkBandwidthGbps: {
      max: 123,
      min: 123,
    },
    networkInterfaceCount: {
      max: 123,
      min: 123,
    },
    onDemandMaxPricePercentageOverLowestPrice: 123,
    requireHibernateSupport: false,
    spotMaxPricePercentageOverLowestPrice: 123,
    totalLocalStorageGb: {
      max: 123,
      min: 123,
    },
  },
  instanceType: instanceType,
  launchTemplate: launchTemplate,
  weightedCapacity: 123,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_autoscaling as autoscaling
from aws_cdk import aws_ec2 as ec2

# instance_type: ec2.InstanceType
# launch_template: ec2.LaunchTemplate

launch_template_overrides = autoscaling.LaunchTemplateOverrides(
    instance_requirements=autoscaling.CfnAutoScalingGroup.InstanceRequirementsProperty(
        memory_mi_b=autoscaling.CfnAutoScalingGroup.MemoryMiBRequestProperty(
            max=123,
            min=123
        ),
        v_cpu_count=autoscaling.CfnAutoScalingGroup.VCpuCountRequestProperty(
            max=123,
            min=123
        ),

        # the properties below are optional
        accelerator_count=autoscaling.CfnAutoScalingGroup.AcceleratorCountRequestProperty(
            max=123,
            min=123
        ),
        accelerator_manufacturers=["acceleratorManufacturers"],
        accelerator_names=["acceleratorNames"],
        accelerator_total_memory_mi_b=autoscaling.CfnAutoScalingGroup.AcceleratorTotalMemoryMiBRequestProperty(
            max=123,
            min=123
        ),
        accelerator_types=["acceleratorTypes"],
        allowed_instance_types=["allowedInstanceTypes"],
        bare_metal="bareMetal",
        baseline_ebs_bandwidth_mbps=autoscaling.CfnAutoScalingGroup.BaselineEbsBandwidthMbpsRequestProperty(
            max=123,
            min=123
        ),
        baseline_performance_factors=autoscaling.CfnAutoScalingGroup.BaselinePerformanceFactorsRequestProperty(
            cpu=autoscaling.CfnAutoScalingGroup.CpuPerformanceFactorRequestProperty(
                references=[autoscaling.CfnAutoScalingGroup.PerformanceFactorReferenceRequestProperty(
                    instance_family="instanceFamily"
                )]
            )
        ),
        burstable_performance="burstablePerformance",
        cpu_manufacturers=["cpuManufacturers"],
        excluded_instance_types=["excludedInstanceTypes"],
        instance_generations=["instanceGenerations"],
        local_storage="localStorage",
        local_storage_types=["localStorageTypes"],
        max_spot_price_as_percentage_of_optimal_on_demand_price=123,
        memory_gi_b_per_v_cpu=autoscaling.CfnAutoScalingGroup.MemoryGiBPerVCpuRequestProperty(
            max=123,
            min=123
        ),
        network_bandwidth_gbps=autoscaling.CfnAutoScalingGroup.NetworkBandwidthGbpsRequestProperty(
            max=123,
            min=123
        ),
        network_interface_count=autoscaling.CfnAutoScalingGroup.NetworkInterfaceCountRequestProperty(
            max=123,
            min=123
        ),
        on_demand_max_price_percentage_over_lowest_price=123,
        require_hibernate_support=False,
        spot_max_price_percentage_over_lowest_price=123,
        total_local_storage_gb=autoscaling.CfnAutoScalingGroup.TotalLocalStorageGBRequestProperty(
            max=123,
            min=123
        )
    ),
    instance_type=instance_type,
    launch_template=launch_template,
    weighted_capacity=123
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.autoscaling.*;
import software.amazon.awscdk.services.ec2.*;

InstanceType instanceType;
LaunchTemplate launchTemplate;

LaunchTemplateOverrides launchTemplateOverrides = LaunchTemplateOverrides.builder()
        .instanceRequirements(InstanceRequirementsProperty.builder()
                .memoryMiB(MemoryMiBRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .vCpuCount(VCpuCountRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())

                // the properties below are optional
                .acceleratorCount(AcceleratorCountRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .acceleratorManufacturers(List.of("acceleratorManufacturers"))
                .acceleratorNames(List.of("acceleratorNames"))
                .acceleratorTotalMemoryMiB(AcceleratorTotalMemoryMiBRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .acceleratorTypes(List.of("acceleratorTypes"))
                .allowedInstanceTypes(List.of("allowedInstanceTypes"))
                .bareMetal("bareMetal")
                .baselineEbsBandwidthMbps(BaselineEbsBandwidthMbpsRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .baselinePerformanceFactors(BaselinePerformanceFactorsRequestProperty.builder()
                        .cpu(CpuPerformanceFactorRequestProperty.builder()
                                .references(List.of(PerformanceFactorReferenceRequestProperty.builder()
                                        .instanceFamily("instanceFamily")
                                        .build()))
                                .build())
                        .build())
                .burstablePerformance("burstablePerformance")
                .cpuManufacturers(List.of("cpuManufacturers"))
                .excludedInstanceTypes(List.of("excludedInstanceTypes"))
                .instanceGenerations(List.of("instanceGenerations"))
                .localStorage("localStorage")
                .localStorageTypes(List.of("localStorageTypes"))
                .maxSpotPriceAsPercentageOfOptimalOnDemandPrice(123)
                .memoryGiBPerVCpu(MemoryGiBPerVCpuRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .networkBandwidthGbps(NetworkBandwidthGbpsRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .networkInterfaceCount(NetworkInterfaceCountRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .onDemandMaxPricePercentageOverLowestPrice(123)
                .requireHibernateSupport(false)
                .spotMaxPricePercentageOverLowestPrice(123)
                .totalLocalStorageGb(TotalLocalStorageGBRequestProperty.builder()
                        .max(123)
                        .min(123)
                        .build())
                .build())
        .instanceType(instanceType)
        .launchTemplate(launchTemplate)
        .weightedCapacity(123)
        .build();
csharp
// 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.AutoScaling;
using Amazon.CDK.AWS.EC2;

InstanceType instanceType;
LaunchTemplate launchTemplate;

var launchTemplateOverrides = new LaunchTemplateOverrides {
    InstanceRequirements = new InstanceRequirementsProperty {
        MemoryMiB = new MemoryMiBRequestProperty {
            Max = 123,
            Min = 123
        },
        VCpuCount = new VCpuCountRequestProperty {
            Max = 123,
            Min = 123
        },

        // the properties below are optional
        AcceleratorCount = new AcceleratorCountRequestProperty {
            Max = 123,
            Min = 123
        },
        AcceleratorManufacturers = new [] { "acceleratorManufacturers" },
        AcceleratorNames = new [] { "acceleratorNames" },
        AcceleratorTotalMemoryMiB = new AcceleratorTotalMemoryMiBRequestProperty {
            Max = 123,
            Min = 123
        },
        AcceleratorTypes = new [] { "acceleratorTypes" },
        AllowedInstanceTypes = new [] { "allowedInstanceTypes" },
        BareMetal = "bareMetal",
        BaselineEbsBandwidthMbps = new BaselineEbsBandwidthMbpsRequestProperty {
            Max = 123,
            Min = 123
        },
        BaselinePerformanceFactors = new BaselinePerformanceFactorsRequestProperty {
            Cpu = new CpuPerformanceFactorRequestProperty {
                References = new [] { new PerformanceFactorReferenceRequestProperty {
                    InstanceFamily = "instanceFamily"
                } }
            }
        },
        BurstablePerformance = "burstablePerformance",
        CpuManufacturers = new [] { "cpuManufacturers" },
        ExcludedInstanceTypes = new [] { "excludedInstanceTypes" },
        InstanceGenerations = new [] { "instanceGenerations" },
        LocalStorage = "localStorage",
        LocalStorageTypes = new [] { "localStorageTypes" },
        MaxSpotPriceAsPercentageOfOptimalOnDemandPrice = 123,
        MemoryGiBPerVCpu = new MemoryGiBPerVCpuRequestProperty {
            Max = 123,
            Min = 123
        },
        NetworkBandwidthGbps = new NetworkBandwidthGbpsRequestProperty {
            Max = 123,
            Min = 123
        },
        NetworkInterfaceCount = new NetworkInterfaceCountRequestProperty {
            Max = 123,
            Min = 123
        },
        OnDemandMaxPricePercentageOverLowestPrice = 123,
        RequireHibernateSupport = false,
        SpotMaxPricePercentageOverLowestPrice = 123,
        TotalLocalStorageGb = new TotalLocalStorageGBRequestProperty {
            Max = 123,
            Min = 123
        }
    },
    InstanceType = instanceType,
    LaunchTemplate = launchTemplate,
    WeightedCapacity = 123
};
go
// 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"
import "github.com/aws/aws-cdk-go/awscdk"

var instanceType InstanceType
var launchTemplate LaunchTemplate

launchTemplateOverrides := &LaunchTemplateOverrides{
	InstanceRequirements: &InstanceRequirementsProperty{
		MemoryMiB: &MemoryMiBRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		VCpuCount: &VCpuCountRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},

		// the properties below are optional
		AcceleratorCount: &AcceleratorCountRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		AcceleratorManufacturers: []*string{
			jsii.String("acceleratorManufacturers"),
		},
		AcceleratorNames: []*string{
			jsii.String("acceleratorNames"),
		},
		AcceleratorTotalMemoryMiB: &AcceleratorTotalMemoryMiBRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		AcceleratorTypes: []*string{
			jsii.String("acceleratorTypes"),
		},
		AllowedInstanceTypes: []*string{
			jsii.String("allowedInstanceTypes"),
		},
		BareMetal: jsii.String("bareMetal"),
		BaselineEbsBandwidthMbps: &BaselineEbsBandwidthMbpsRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		BaselinePerformanceFactors: &BaselinePerformanceFactorsRequestProperty{
			Cpu: &CpuPerformanceFactorRequestProperty{
				References: []interface{}{
					&PerformanceFactorReferenceRequestProperty{
						InstanceFamily: jsii.String("instanceFamily"),
					},
				},
			},
		},
		BurstablePerformance: jsii.String("burstablePerformance"),
		CpuManufacturers: []*string{
			jsii.String("cpuManufacturers"),
		},
		ExcludedInstanceTypes: []*string{
			jsii.String("excludedInstanceTypes"),
		},
		InstanceGenerations: []*string{
			jsii.String("instanceGenerations"),
		},
		LocalStorage: jsii.String("localStorage"),
		LocalStorageTypes: []*string{
			jsii.String("localStorageTypes"),
		},
		MaxSpotPriceAsPercentageOfOptimalOnDemandPrice: jsii.Number(123),
		MemoryGiBPerVCpu: &MemoryGiBPerVCpuRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		NetworkBandwidthGbps: &NetworkBandwidthGbpsRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		NetworkInterfaceCount: &NetworkInterfaceCountRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
		OnDemandMaxPricePercentageOverLowestPrice: jsii.Number(123),
		RequireHibernateSupport: jsii.Boolean(false),
		SpotMaxPricePercentageOverLowestPrice: jsii.Number(123),
		TotalLocalStorageGb: &TotalLocalStorageGBRequestProperty{
			Max: jsii.Number(123),
			Min: jsii.Number(123),
		},
	},
	InstanceType: instanceType,
	LaunchTemplate: launchTemplate,
	WeightedCapacity: jsii.Number(123),
}

Properties ​

instanceRequirementsoptionalCfnAutoScalingGroup.InstanceRequirementsPropertyinstance_requirementsoptionalInstanceRequirementsPropertyinstanceRequirementsoptionalInstanceRequirementsPropertyInstanceRequirementsoptionalInstanceRequirementsPropertyInstanceRequirementsoptionalInstanceRequirementsProperty#
The instance requirements.

Default: Do not override instance type

notes

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.

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

Default: Do not override instance type

You must specify one of instanceRequirements or instanceType.

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

Default: Do not override launch template

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.

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

Default: Do not provide weight

notes

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.