Skip to content
v2.274.0

InstanceRequirementsConfig Struct ​

The attributes for the instance types for a mixed instances policy.

When you specify multiple attributes, you get instance types that satisfy all of the specified attributes. If you specify multiple values for an attribute, you get instance types that satisfy any of the specified values.

To limit the list of instance types from which Amazon EC2 can identify matching instance types, you can use one of the following parameters, but not both in the same request:

  • AllowedInstanceTypes - The instance types to include in the list. All other instance types are ignored, even if they match your specified attributes.
  • ExcludedInstanceTypes - The instance types to exclude from the list, even if they match your specified attributes.

Note: You must specify VCpuCount and MemoryMiB. All other attributes are optional. Any unspecified optional attribute is set to its default.

Example ​

ts
declare const vpc: ec2.Vpc;

const cluster = new ecs.Cluster(this, 'Cluster', { vpc });

const securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', {
  vpc,
  description: 'Security group for managed instances',
});

const miCapacityProvider = new ecs.ManagedInstancesCapacityProvider(this, 'MICapacityProvider', {
  capacityOptionType: ecs.CapacityOptionType.SPOT,
  subnets: vpc.privateSubnets,
  securityGroups: [securityGroup],
  instanceRequirements: {
    vCpuCountMin: 1,
    memoryMin: Size.gibibytes(2),
  },
});

// Optionally configure security group rules using IConnectable interface
miCapacityProvider.connections.allowFrom(ec2.Peer.ipv4(vpc.vpcCidrBlock), ec2.Port.tcp(80));

// Add the capacity provider to the cluster
cluster.addManagedInstancesCapacityProvider(miCapacityProvider);

const taskDefinition = new ecs.TaskDefinition(this, 'TaskDef', {
  memoryMiB: '512',
  cpu: '256',
  networkMode: ecs.NetworkMode.AWS_VPC,
  compatibility: ecs.Compatibility.MANAGED_INSTANCES,
});

taskDefinition.addContainer('web', {
  image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
  memoryReservationMiB: 256,
});

new ecs.FargateService(this, 'FargateService', {
  cluster,
  taskDefinition,
  minHealthyPercent: 100,
  capacityProviderStrategies: [
    {
      capacityProvider: miCapacityProvider.capacityProviderName,
      weight: 1,
    },
  ],
});

Properties ​

acceleratorCountMaxnumberaccelerator_count_maxint | floatacceleratorCountMaxNumberAcceleratorCountMaxdoubleAcceleratorCountMax*float64#
The maximum number of accelerators (GPUs, FPGAs, or AWS Inferentia chips) for an instance type.

Default: No minimum or maximum limits

To exclude accelerator-enabled instance types, set Max to 0.

acceleratorCountMinnumberaccelerator_count_minint | floatacceleratorCountMinNumberAcceleratorCountMindoubleAcceleratorCountMin*float64#
The minimum number of accelerators (GPUs, FPGAs, or AWS Inferentia chips) for an instance type.

Default: No minimum or maximum limits

To exclude accelerator-enabled instance types, set acceleratorCountMax to 0.

acceleratorManufacturersAcceleratorManufacturer[]accelerator_manufacturerstyping.List[AcceleratorManufacturer]acceleratorManufacturersList<AcceleratorManufacturer>AcceleratorManufacturersAcceleratorManufacturer[]AcceleratorManufacturers*[]AcceleratorManufacturer#
Indicates whether instance types must have accelerators by specific manufacturers.

Default: Any manufacturer

  • For instance types with NVIDIA devices, specify nvidia.
  • For instance types with AMD devices, specify amd.
  • For instance types with AWS devices, specify amazon-web-services.
  • For instance types with Xilinx devices, specify xilinx.
acceleratorNamesAcceleratorName[]accelerator_namestyping.List[AcceleratorName]acceleratorNamesList<AcceleratorName>AcceleratorNamesAcceleratorName[]AcceleratorNames*[]AcceleratorName#
Lists the accelerators that must be on an instance type.

Default: Any accelerator

notes
  • For instance types with NVIDIA A100 GPUs, specify a100.
  • For instance types with NVIDIA V100 GPUs, specify v100.
  • For instance types with NVIDIA K80 GPUs, specify k80.
  • For instance types with NVIDIA T4 GPUs, specify t4.
  • For instance types with NVIDIA M60 GPUs, specify m60.
  • For instance types with AMD Radeon Pro V520 GPUs, specify radeon-pro-v520.
  • For instance types with Xilinx VU9P FPGAs, specify vu9p.
acceleratorTotalMemoryMaxSizeaccelerator_total_memory_maxSizeacceleratorTotalMemoryMaxSizeAcceleratorTotalMemoryMaxSizeAcceleratorTotalMemoryMaxSize#
The maximum total memory size for the accelerators on an instance type, in MiB.

Default: No minimum or maximum limits

acceleratorTotalMemoryMinSizeaccelerator_total_memory_minSizeacceleratorTotalMemoryMinSizeAcceleratorTotalMemoryMinSizeAcceleratorTotalMemoryMinSize#
The minimum total memory size for the accelerators on an instance type, in MiB.

Default: No minimum or maximum limits

acceleratorTypesAcceleratorType[]accelerator_typestyping.List[AcceleratorType]acceleratorTypesList<AcceleratorType>AcceleratorTypesAcceleratorType[]AcceleratorTypes*[]AcceleratorType#
Lists the accelerator types that must be on an instance type.

Default: Any accelerator type

  • For instance types with GPU accelerators, specify gpu.
  • For instance types with FPGA accelerators, specify fpga.
  • For instance types with inference accelerators, specify inference.
allowedInstanceTypesstring[]allowed_instance_typestyping.List[str]allowedInstanceTypesList<String>AllowedInstanceTypesstring[]AllowedInstanceTypes*[]*string#
The instance types to apply your specified attributes against.

Default: All instance types

notes

All other instance types are ignored, even if they match your specified attributes.

You can use strings with one or more wild cards, represented by an asterisk (), to allow an instance type, size, or generation. The following are examples: m5.8xlarge, c5., m5a., r*, 3.

For example, if you specify c5*, Amazon EC2 Auto Scaling will allow the entire C5 instance family, which includes all C5a and C5n instance types. If you specify m5a.*, Amazon EC2 Auto Scaling will allow all the M5a instance types, but not the M5n instance types.

Note: If you specify AllowedInstanceTypes, you can't specify ExcludedInstanceTypes.

bareMetalBareMetalbare_metalBareMetalbareMetalBareMetalBareMetalBareMetalBareMetalBareMetal= excluded#
Indicates whether bare metal instance types are included, excluded, or required.
baselineEbsBandwidthMbpsMaxnumberbaseline_ebs_bandwidth_mbps_maxint | floatbaselineEbsBandwidthMbpsMaxNumberBaselineEbsBandwidthMbpsMaxdoubleBaselineEbsBandwidthMbpsMax*float64#
The maximum baseline bandwidth performance for an instance type, in Mbps.

Default: No minimum or maximum limits

For more information, see Amazon EBS–optimized instances in the Amazon EC2 User Guide.

baselineEbsBandwidthMbpsMinnumberbaseline_ebs_bandwidth_mbps_minint | floatbaselineEbsBandwidthMbpsMinNumberBaselineEbsBandwidthMbpsMindoubleBaselineEbsBandwidthMbpsMin*float64#
The minimum baseline bandwidth performance for an instance type, in Mbps.

Default: No minimum or maximum limits

For more information, see Amazon EBS–optimized instances in the Amazon EC2 User Guide.

burstablePerformanceBurstablePerformanceburstable_performanceBurstablePerformanceburstablePerformanceBurstablePerformanceBurstablePerformanceBurstablePerformanceBurstablePerformanceBurstablePerformance= excluded#
Indicates whether burstable performance instance types are included, excluded, or required.

For more information, see Burstable performance instances in the Amazon EC2 User Guide.

cpuManufacturersCpuManufacturer[]cpu_manufacturerstyping.List[CpuManufacturer]cpuManufacturersList<CpuManufacturer>CpuManufacturersCpuManufacturer[]CpuManufacturers*[]CpuManufacturer#
Lists which specific CPU manufacturers to include.

Default: Any manufacturer

notes
  • For instance types with Intel CPUs, specify intel.
  • For instance types with AMD CPUs, specify amd.
  • For instance types with AWS CPUs, specify amazon-web-services.
  • For instance types with Apple CPUs, specify apple.

Note: Don't confuse the CPU hardware manufacturer with the CPU hardware architecture. Instances will be launched with a compatible CPU architecture based on the Amazon Machine Image (AMI) that you specify in your launch template.

excludedInstanceTypesstring[]excluded_instance_typestyping.List[str]excludedInstanceTypesList<String>ExcludedInstanceTypesstring[]ExcludedInstanceTypes*[]*string#
The instance types to exclude.

Default: No excluded instance types

notes

You can use strings with one or more wild cards, represented by an asterisk (), to exclude an instance family, type, size, or generation. The following are examples: m5.8xlarge, c5., m5a., r*, 3.

For example, if you specify c5*, you are excluding the entire C5 instance family, which includes all C5a and C5n instance types. If you specify m5a.*, Amazon EC2 Auto Scaling will exclude all the M5a instance types, but not the M5n instance types.

Note: If you specify ExcludedInstanceTypes, you can't specify AllowedInstanceTypes.

instanceGenerationsInstanceGeneration[]instance_generationstyping.List[InstanceGeneration]instanceGenerationsList<InstanceGeneration>InstanceGenerationsInstanceGeneration[]InstanceGenerations*[]InstanceGeneration#
Indicates whether current or previous generation instance types are included.

Default: Any current or previous generation

notes
  • For current generation instance types, specify current. The current generation includes EC2 instance types currently recommended for use. This typically includes the latest two to three generations in each instance family. For more information, see Instance types in the Amazon EC2 User Guide.
  • For previous generation instance types, specify previous.
localStorageLocalStoragelocal_storageLocalStoragelocalStorageLocalStorageLocalStorageLocalStorageLocalStorageLocalStorage= included#
Indicates whether instance types with instance store volumes are included, excluded, or required.

For more information, see Amazon EC2 instance store in the Amazon EC2 User Guide.

localStorageTypesLocalStorageType[]local_storage_typestyping.List[LocalStorageType]localStorageTypesList<LocalStorageType>LocalStorageTypesLocalStorageType[]LocalStorageTypes*[]LocalStorageType#
Indicates the type of local storage that is required.

Default: Any local storage type

  • For instance types with hard disk drive (HDD) storage, specify hdd.
  • For instance types with solid state drive (SSD) storage, specify ssd.
maxSpotPriceAsPercentageOfOptimalOnDemandPricenumbermax_spot_price_as_percentage_of_optimal_on_demand_priceint | floatmaxSpotPriceAsPercentageOfOptimalOnDemandPriceNumberMaxSpotPriceAsPercentageOfOptimalOnDemandPricedoubleMaxSpotPriceAsPercentageOfOptimalOnDemandPrice*float64#
[Price protection] The price protection threshold for Spot Instances, as a percentage of an identified On-Demand price.

Default: Automatic optimal price protection

notes

The identified On-Demand price is the price of the lowest priced current generation C, M, or R instance type with your specified attributes. If no current generation C, M, or R instance type matches your attributes, then the identified price is from either the lowest priced current generation instance types or, failing that, the lowest priced previous generation instance types that match your attributes. When Amazon EC2 Auto Scaling selects instance types with your attributes, we will exclude instance types whose price exceeds your specified threshold.

The parameter accepts an integer, which Amazon EC2 Auto Scaling interprets as a percentage.

If you set DesiredCapacityType to vcpu or memory-mib, the price protection threshold is based on the per-vCPU or per-memory price instead of the per instance price.

Note: Only one of SpotMaxPricePercentageOverLowestPrice or MaxSpotPriceAsPercentageOfOptimalOnDemandPrice can be specified. If you don't specify either, Amazon EC2 Auto Scaling will automatically apply optimal price protection to consistently select from a wide range of instance types. To indicate no price protection threshold for Spot Instances, meaning you want to consider all instance types that match your attributes, include one of these parameters and specify a high value, such as 999999.

memoryMaxSizememory_maxSizememoryMaxSizeMemoryMaxSizeMemoryMaxSize#
The maximum instance memory size for an instance type, in MiB.

Default: No maximum limit

memoryMinSizememory_minSizememoryMinSizeMemoryMinSizeMemoryMinSizerequired#
The minimum instance memory size for an instance type, in MiB.

Required: Yes

memoryPerVCpuMaxSizememory_per_v_cpu_maxSizememoryPerVCpuMaxSizeMemoryPerVCpuMaxSizeMemoryPerVCpuMaxSize#
The maximum amount of memory per vCPU for an instance type, in GiB.

Default: No minimum or maximum limits

memoryPerVCpuMinSizememory_per_v_cpu_minSizememoryPerVCpuMinSizeMemoryPerVCpuMinSizeMemoryPerVCpuMinSize#
The minimum amount of memory per vCPU for an instance type, in GiB.

Default: No minimum or maximum limits

networkBandwidthGbpsMaxnumbernetwork_bandwidth_gbps_maxint | floatnetworkBandwidthGbpsMaxNumberNetworkBandwidthGbpsMaxdoubleNetworkBandwidthGbpsMax*float64#
The maximum amount of network bandwidth, in gigabits per second (Gbps).

Default: No minimum or maximum limits

networkBandwidthGbpsMinnumbernetwork_bandwidth_gbps_minint | floatnetworkBandwidthGbpsMinNumberNetworkBandwidthGbpsMindoubleNetworkBandwidthGbpsMin*float64#
The minimum amount of network bandwidth, in gigabits per second (Gbps).

Default: No minimum or maximum limits

networkInterfaceCountMaxnumbernetwork_interface_count_maxint | floatnetworkInterfaceCountMaxNumberNetworkInterfaceCountMaxdoubleNetworkInterfaceCountMax*float64#
The maximum number of network interfaces for an instance type.

Default: No minimum or maximum limits

networkInterfaceCountMinnumbernetwork_interface_count_minint | floatnetworkInterfaceCountMinNumberNetworkInterfaceCountMindoubleNetworkInterfaceCountMin*float64#
The minimum number of network interfaces for an instance type.

Default: No minimum or maximum limits

onDemandMaxPricePercentageOverLowestPricenumberon_demand_max_price_percentage_over_lowest_priceint | floatonDemandMaxPricePercentageOverLowestPriceNumberOnDemandMaxPricePercentageOverLowestPricedoubleOnDemandMaxPricePercentageOverLowestPrice*float64= 20#
[Price protection] The price protection threshold for On-Demand Instances, as a percentage higher than an identified On-Demand price.
notes

The identified On-Demand price is the price of the lowest priced current generation C, M, or R instance type with your specified attributes. If no current generation C, M, or R instance type matches your attributes, then the identified price is from either the lowest priced current generation instance types or, failing that, the lowest priced previous generation instance types that match your attributes. When Amazon EC2 Auto Scaling selects instance types with your attributes, we will exclude instance types whose price exceeds your specified threshold.

The parameter accepts an integer, which Amazon EC2 Auto Scaling interprets as a percentage.

To turn off price protection, specify a high value, such as 999999.

If you set DesiredCapacityType to vcpu or memory-mib, the price protection threshold is applied based on the per-vCPU or per-memory price instead of the per instance price.

requireHibernateSupportbooleanrequire_hibernate_supportboolrequireHibernateSupportBooleanRequireHibernateSupportboolRequireHibernateSupport*bool= false#
Indicates whether instance types must provide On-Demand Instance hibernation support.
spotMaxPricePercentageOverLowestPricenumberspot_max_price_percentage_over_lowest_priceint | floatspotMaxPricePercentageOverLowestPriceNumberSpotMaxPricePercentageOverLowestPricedoubleSpotMaxPricePercentageOverLowestPrice*float64#
[Price protection] The price protection threshold for Spot Instances, as a percentage higher than an identified Spot price.

Default: Automatic optimal price protection

notes

The identified Spot price is the price of the lowest priced current generation C, M, or R instance type with your specified attributes. If no current generation C, M, or R instance type matches your attributes, then the identified price is from either the lowest priced current generation instance types or, failing that, the lowest priced previous generation instance types that match your attributes. When Amazon EC2 Auto Scaling selects instance types with your attributes, we will exclude instance types whose price exceeds your specified threshold.

The parameter accepts an integer, which Amazon EC2 Auto Scaling interprets as a percentage.

If you set DesiredCapacityType to vcpu or memory-mib, the price protection threshold is based on the per-vCPU or per-memory price instead of the per instance price.

Note: Only one of SpotMaxPricePercentageOverLowestPrice or MaxSpotPriceAsPercentageOfOptimalOnDemandPrice can be specified. If you don't specify either, Amazon EC2 Auto Scaling will automatically apply optimal price protection to consistently select from a wide range of instance types. To indicate no price protection threshold for Spot Instances, meaning you want to consider all instance types that match your attributes, include one of these parameters and specify a high value, such as 999999.

totalLocalStorageGBMaxnumbertotal_local_storage_gb_maxint | floattotalLocalStorageGBMaxNumberTotalLocalStorageGBMaxdoubleTotalLocalStorageGBMax*float64#
The maximum total local storage size for an instance type, in GB.

Default: No minimum or maximum limits

totalLocalStorageGBMinnumbertotal_local_storage_gb_minint | floattotalLocalStorageGBMinNumberTotalLocalStorageGBMindoubleTotalLocalStorageGBMin*float64#
The minimum total local storage size for an instance type, in GB.

Default: No minimum or maximum limits

vCpuCountMaxnumberv_cpu_count_maxint | floatvCpuCountMaxNumberVCpuCountMaxdoubleVCpuCountMax*float64#
The maximum number of vCPUs for an instance type.

Default: No maximum limit

vCpuCountMinnumberv_cpu_count_minint | floatvCpuCountMinNumberVCpuCountMindoubleVCpuCountMin*float64required#
The minimum number of vCPUs for an instance type.

Required: Yes