Skip to content
v2.274.0

CfnEC2Fleet L1 construct ​

Specifies the configuration information to launch a fleet--or group--of instances.

An EC2 Fleet can launch multiple instance types across multiple Availability Zones, using the On-Demand Instance, Reserved Instance, and Spot Instance purchasing models together. Using EC2 Fleet, you can define separate On-Demand and Spot capacity targets, specify the instance types that work best for your applications, and specify how Amazon EC2 should distribute your fleet capacity within each purchasing model. For more information, see Launching an EC2 Fleet in the Amazon EC2 User Guide .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
const cfnEC2Fleet = new ec2.CfnEC2Fleet(this, 'MyCfnEC2Fleet', {
  launchTemplateConfigs: [{
    launchTemplateSpecification: {
      version: 'version',

      // the properties below are optional
      launchTemplateId: 'launchTemplateId',
      launchTemplateName: 'launchTemplateName',
      launchTemplateSpecificationUserData: 'launchTemplateSpecificationUserData',
    },
    overrides: [{
      availabilityZone: 'availabilityZone',
      availabilityZoneId: 'availabilityZoneId',
      blockDeviceMappings: [{
        deviceName: 'deviceName',
        ebs: {
          deleteOnTermination: false,
          encrypted: false,
          iops: 123,
          kmsKeyId: 'kmsKeyId',
          multiAvailabilityZoneConfiguration: {
            configurationType: 'configurationType',
            standbyAvailabilityZones: [{
              availabilityZone: 'availabilityZone',
              availabilityZoneId: 'availabilityZoneId',
            }],
          },
          snapshotId: 'snapshotId',
          volumeSize: 123,
          volumeType: 'volumeType',
        },
        noDevice: 'noDevice',
        virtualName: 'virtualName',
      }],
      iamInstanceProfile: {
        arn: 'arn',
        name: 'name',
      },
      instanceRequirements: {
        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,
        },
        memoryMiB: {
          max: 123,
          min: 123,
        },
        networkBandwidthGbps: {
          max: 123,
          min: 123,
        },
        networkInterfaceCount: {
          max: 123,
          min: 123,
        },
        onDemandMaxPricePercentageOverLowestPrice: 123,
        requireEncryptionInTransit: false,
        requireHibernateSupport: false,
        spotMaxPricePercentageOverLowestPrice: 123,
        totalLocalStorageGb: {
          max: 123,
          min: 123,
        },
        vCpuCount: {
          max: 123,
          min: 123,
        },
      },
      instanceType: 'instanceType',
      keyName: 'keyName',
      maxPrice: 'maxPrice',
      metadataOptions: {
        httpEndpoint: 'httpEndpoint',
        httpPutResponseHopLimit: 123,
        httpTokens: 'httpTokens',
      },
      networkInterfaces: [{
        associatePublicIpAddress: false,
        deleteOnTermination: false,
        description: 'description',
        deviceIndex: 123,
        groups: ['groups'],
        interfaceType: 'interfaceType',
        ipv6AddressCount: 123,
        ipv6Addresses: [{
          ipv6Address: 'ipv6Address',
        }],
        networkCardIndex: 123,
        networkInterfaceId: 'networkInterfaceId',
        privateIpAddress: 'privateIpAddress',
        privateIpAddresses: [{
          primary: false,
          privateIpAddress: 'privateIpAddress',
        }],
        secondaryPrivateIpAddressCount: 123,
        subnetId: 'subnetId',
      }],
      placement: {
        affinity: 'affinity',
        availabilityZone: 'availabilityZone',
        groupName: 'groupName',
        hostId: 'hostId',
        hostResourceGroupArn: 'hostResourceGroupArn',
        partitionNumber: 123,
        spreadDomain: 'spreadDomain',
        tenancy: 'tenancy',
      },
      priority: 123,
      subnetId: 'subnetId',
      weightedCapacity: 123,
    }],
  }],
  targetCapacitySpecification: {
    totalTargetCapacity: 123,

    // the properties below are optional
    defaultTargetCapacityType: 'defaultTargetCapacityType',
    onDemandTargetCapacity: 123,
    spotTargetCapacity: 123,
    targetCapacityUnitType: 'targetCapacityUnitType',
  },

  // the properties below are optional
  context: 'context',
  excessCapacityTerminationPolicy: 'excessCapacityTerminationPolicy',
  onDemandOptions: {
    allocationStrategy: 'allocationStrategy',
    capacityReservationOptions: {
      usageStrategy: 'usageStrategy',
    },
    maxTotalPrice: 'maxTotalPrice',
    minTargetCapacity: 123,
    singleAvailabilityZone: false,
    singleInstanceType: false,
  },
  replaceUnhealthyInstances: false,
  reservedCapacityOptions: {
    allocationStrategy: 'allocationStrategy',
    capacityReservationTarget: {
      capacityReservationIds: ['capacityReservationIds'],
      capacityReservationResourceGroupArns: ['capacityReservationResourceGroupArns'],
    },
    reservationTypes: ['reservationTypes'],
    reservedCapacityFallbackOptions: {
      marketTypes: ['marketTypes'],
    },
  },
  spotOptions: {
    allocationStrategy: 'allocationStrategy',
    instanceInterruptionBehavior: 'instanceInterruptionBehavior',
    instancePoolsToUseCount: 123,
    maintenanceStrategies: {
      capacityRebalance: {
        replacementStrategy: 'replacementStrategy',
        terminationDelay: 123,
      },
    },
    maxTotalPrice: 'maxTotalPrice',
    minTargetCapacity: 123,
    singleAvailabilityZone: false,
    singleInstanceType: false,
  },
  tagSpecifications: [{
    resourceType: 'resourceType',
    tags: [{
      key: 'key',
      value: 'value',
    }],
  }],
  terminateInstancesWithExpiration: false,
  type: 'type',
  validFrom: 'validFrom',
  validUntil: 'validUntil',
});
python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2

cfn_ec2_fleet = ec2.CfnEC2Fleet(self, "MyCfnEC2Fleet",
    launch_template_configs=[ec2.CfnEC2Fleet.FleetLaunchTemplateConfigRequestProperty(
        launch_template_specification=ec2.CfnEC2Fleet.FleetLaunchTemplateSpecificationRequestProperty(
            version="version",

            # the properties below are optional
            launch_template_id="launchTemplateId",
            launch_template_name="launchTemplateName",
            launch_template_specification_user_data="launchTemplateSpecificationUserData"
        ),
        overrides=[ec2.CfnEC2Fleet.FleetLaunchTemplateOverridesRequestProperty(
            availability_zone="availabilityZone",
            availability_zone_id="availabilityZoneId",
            block_device_mappings=[ec2.CfnEC2Fleet.BlockDeviceMappingProperty(
                device_name="deviceName",
                ebs=ec2.CfnEC2Fleet.EbsBlockDeviceProperty(
                    delete_on_termination=False,
                    encrypted=False,
                    iops=123,
                    kms_key_id="kmsKeyId",
                    multi_availability_zone_configuration=ec2.CfnEC2Fleet.MultiAvailabilityZoneConfigurationProperty(
                        configuration_type="configurationType",
                        standby_availability_zones=[ec2.CfnEC2Fleet.StandbyAvailabilityZoneProperty(
                            availability_zone="availabilityZone",
                            availability_zone_id="availabilityZoneId"
                        )]
                    ),
                    snapshot_id="snapshotId",
                    volume_size=123,
                    volume_type="volumeType"
                ),
                no_device="noDevice",
                virtual_name="virtualName"
            )],
            iam_instance_profile=ec2.CfnEC2Fleet.IamInstanceProfileSpecificationProperty(
                arn="arn",
                name="name"
            ),
            instance_requirements=ec2.CfnEC2Fleet.InstanceRequirementsRequestProperty(
                accelerator_count=ec2.CfnEC2Fleet.AcceleratorCountRequestProperty(
                    max=123,
                    min=123
                ),
                accelerator_manufacturers=["acceleratorManufacturers"],
                accelerator_names=["acceleratorNames"],
                accelerator_total_memory_mi_b=ec2.CfnEC2Fleet.AcceleratorTotalMemoryMiBRequestProperty(
                    max=123,
                    min=123
                ),
                accelerator_types=["acceleratorTypes"],
                allowed_instance_types=["allowedInstanceTypes"],
                bare_metal="bareMetal",
                baseline_ebs_bandwidth_mbps=ec2.CfnEC2Fleet.BaselineEbsBandwidthMbpsRequestProperty(
                    max=123,
                    min=123
                ),
                baseline_performance_factors=ec2.CfnEC2Fleet.BaselinePerformanceFactorsRequestProperty(
                    cpu=ec2.CfnEC2Fleet.CpuPerformanceFactorRequestProperty(
                        references=[ec2.CfnEC2Fleet.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=ec2.CfnEC2Fleet.MemoryGiBPerVCpuRequestProperty(
                    max=123,
                    min=123
                ),
                memory_mi_b=ec2.CfnEC2Fleet.MemoryMiBRequestProperty(
                    max=123,
                    min=123
                ),
                network_bandwidth_gbps=ec2.CfnEC2Fleet.NetworkBandwidthGbpsRequestProperty(
                    max=123,
                    min=123
                ),
                network_interface_count=ec2.CfnEC2Fleet.NetworkInterfaceCountRequestProperty(
                    max=123,
                    min=123
                ),
                on_demand_max_price_percentage_over_lowest_price=123,
                require_encryption_in_transit=False,
                require_hibernate_support=False,
                spot_max_price_percentage_over_lowest_price=123,
                total_local_storage_gb=ec2.CfnEC2Fleet.TotalLocalStorageGBRequestProperty(
                    max=123,
                    min=123
                ),
                v_cpu_count=ec2.CfnEC2Fleet.VCpuCountRangeRequestProperty(
                    max=123,
                    min=123
                )
            ),
            instance_type="instanceType",
            key_name="keyName",
            max_price="maxPrice",
            metadata_options=ec2.CfnEC2Fleet.InstanceMetadataOptionsRequestProperty(
                http_endpoint="httpEndpoint",
                http_put_response_hop_limit=123,
                http_tokens="httpTokens"
            ),
            network_interfaces=[ec2.CfnEC2Fleet.NetworkInterfaceSpecificationRequestProperty(
                associate_public_ip_address=False,
                delete_on_termination=False,
                description="description",
                device_index=123,
                groups=["groups"],
                interface_type="interfaceType",
                ipv6_address_count=123,
                ipv6_addresses=[ec2.CfnEC2Fleet.Ipv6AddressRequestProperty(
                    ipv6_address="ipv6Address"
                )],
                network_card_index=123,
                network_interface_id="networkInterfaceId",
                private_ip_address="privateIpAddress",
                private_ip_addresses=[ec2.CfnEC2Fleet.PrivateIpAddressSpecificationRequestProperty(
                    primary=False,
                    private_ip_address="privateIpAddress"
                )],
                secondary_private_ip_address_count=123,
                subnet_id="subnetId"
            )],
            placement=ec2.CfnEC2Fleet.PlacementProperty(
                affinity="affinity",
                availability_zone="availabilityZone",
                group_name="groupName",
                host_id="hostId",
                host_resource_group_arn="hostResourceGroupArn",
                partition_number=123,
                spread_domain="spreadDomain",
                tenancy="tenancy"
            ),
            priority=123,
            subnet_id="subnetId",
            weighted_capacity=123
        )]
    )],
    target_capacity_specification=ec2.CfnEC2Fleet.TargetCapacitySpecificationRequestProperty(
        total_target_capacity=123,

        # the properties below are optional
        default_target_capacity_type="defaultTargetCapacityType",
        on_demand_target_capacity=123,
        spot_target_capacity=123,
        target_capacity_unit_type="targetCapacityUnitType"
    ),

    # the properties below are optional
    context="context",
    excess_capacity_termination_policy="excessCapacityTerminationPolicy",
    on_demand_options=ec2.CfnEC2Fleet.OnDemandOptionsRequestProperty(
        allocation_strategy="allocationStrategy",
        capacity_reservation_options=ec2.CfnEC2Fleet.CapacityReservationOptionsRequestProperty(
            usage_strategy="usageStrategy"
        ),
        max_total_price="maxTotalPrice",
        min_target_capacity=123,
        single_availability_zone=False,
        single_instance_type=False
    ),
    replace_unhealthy_instances=False,
    reserved_capacity_options=ec2.CfnEC2Fleet.ReservedCapacityOptionsRequestProperty(
        allocation_strategy="allocationStrategy",
        capacity_reservation_target=ec2.CfnEC2Fleet.CapacityReservationTargetRequestProperty(
            capacity_reservation_ids=["capacityReservationIds"],
            capacity_reservation_resource_group_arns=["capacityReservationResourceGroupArns"]
        ),
        reservation_types=["reservationTypes"],
        reserved_capacity_fallback_options=ec2.CfnEC2Fleet.ReservedCapacityFallbackOptionsRequestProperty(
            market_types=["marketTypes"]
        )
    ),
    spot_options=ec2.CfnEC2Fleet.SpotOptionsRequestProperty(
        allocation_strategy="allocationStrategy",
        instance_interruption_behavior="instanceInterruptionBehavior",
        instance_pools_to_use_count=123,
        maintenance_strategies=ec2.CfnEC2Fleet.MaintenanceStrategiesProperty(
            capacity_rebalance=ec2.CfnEC2Fleet.CapacityRebalanceProperty(
                replacement_strategy="replacementStrategy",
                termination_delay=123
            )
        ),
        max_total_price="maxTotalPrice",
        min_target_capacity=123,
        single_availability_zone=False,
        single_instance_type=False
    ),
    tag_specifications=[ec2.CfnEC2Fleet.TagSpecificationProperty(
        resource_type="resourceType",
        tags=[CfnTag(
            key="key",
            value="value"
        )]
    )],
    terminate_instances_with_expiration=False,
    type="type",
    valid_from="validFrom",
    valid_until="validUntil"
)
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.ec2.*;

CfnEC2Fleet cfnEC2Fleet = CfnEC2Fleet.Builder.create(this, "MyCfnEC2Fleet")
        .launchTemplateConfigs(List.of(FleetLaunchTemplateConfigRequestProperty.builder()
                .launchTemplateSpecification(FleetLaunchTemplateSpecificationRequestProperty.builder()
                        .version("version")

                        // the properties below are optional
                        .launchTemplateId("launchTemplateId")
                        .launchTemplateName("launchTemplateName")
                        .launchTemplateSpecificationUserData("launchTemplateSpecificationUserData")
                        .build())
                .overrides(List.of(FleetLaunchTemplateOverridesRequestProperty.builder()
                        .availabilityZone("availabilityZone")
                        .availabilityZoneId("availabilityZoneId")
                        .blockDeviceMappings(List.of(BlockDeviceMappingProperty.builder()
                                .deviceName("deviceName")
                                .ebs(EbsBlockDeviceProperty.builder()
                                        .deleteOnTermination(false)
                                        .encrypted(false)
                                        .iops(123)
                                        .kmsKeyId("kmsKeyId")
                                        .multiAvailabilityZoneConfiguration(MultiAvailabilityZoneConfigurationProperty.builder()
                                                .configurationType("configurationType")
                                                .standbyAvailabilityZones(List.of(StandbyAvailabilityZoneProperty.builder()
                                                        .availabilityZone("availabilityZone")
                                                        .availabilityZoneId("availabilityZoneId")
                                                        .build()))
                                                .build())
                                        .snapshotId("snapshotId")
                                        .volumeSize(123)
                                        .volumeType("volumeType")
                                        .build())
                                .noDevice("noDevice")
                                .virtualName("virtualName")
                                .build()))
                        .iamInstanceProfile(IamInstanceProfileSpecificationProperty.builder()
                                .arn("arn")
                                .name("name")
                                .build())
                        .instanceRequirements(InstanceRequirementsRequestProperty.builder()
                                .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())
                                .memoryMiB(MemoryMiBRequestProperty.builder()
                                        .max(123)
                                        .min(123)
                                        .build())
                                .networkBandwidthGbps(NetworkBandwidthGbpsRequestProperty.builder()
                                        .max(123)
                                        .min(123)
                                        .build())
                                .networkInterfaceCount(NetworkInterfaceCountRequestProperty.builder()
                                        .max(123)
                                        .min(123)
                                        .build())
                                .onDemandMaxPricePercentageOverLowestPrice(123)
                                .requireEncryptionInTransit(false)
                                .requireHibernateSupport(false)
                                .spotMaxPricePercentageOverLowestPrice(123)
                                .totalLocalStorageGb(TotalLocalStorageGBRequestProperty.builder()
                                        .max(123)
                                        .min(123)
                                        .build())
                                .vCpuCount(VCpuCountRangeRequestProperty.builder()
                                        .max(123)
                                        .min(123)
                                        .build())
                                .build())
                        .instanceType("instanceType")
                        .keyName("keyName")
                        .maxPrice("maxPrice")
                        .metadataOptions(InstanceMetadataOptionsRequestProperty.builder()
                                .httpEndpoint("httpEndpoint")
                                .httpPutResponseHopLimit(123)
                                .httpTokens("httpTokens")
                                .build())
                        .networkInterfaces(List.of(NetworkInterfaceSpecificationRequestProperty.builder()
                                .associatePublicIpAddress(false)
                                .deleteOnTermination(false)
                                .description("description")
                                .deviceIndex(123)
                                .groups(List.of("groups"))
                                .interfaceType("interfaceType")
                                .ipv6AddressCount(123)
                                .ipv6Addresses(List.of(Ipv6AddressRequestProperty.builder()
                                        .ipv6Address("ipv6Address")
                                        .build()))
                                .networkCardIndex(123)
                                .networkInterfaceId("networkInterfaceId")
                                .privateIpAddress("privateIpAddress")
                                .privateIpAddresses(List.of(PrivateIpAddressSpecificationRequestProperty.builder()
                                        .primary(false)
                                        .privateIpAddress("privateIpAddress")
                                        .build()))
                                .secondaryPrivateIpAddressCount(123)
                                .subnetId("subnetId")
                                .build()))
                        .placement(PlacementProperty.builder()
                                .affinity("affinity")
                                .availabilityZone("availabilityZone")
                                .groupName("groupName")
                                .hostId("hostId")
                                .hostResourceGroupArn("hostResourceGroupArn")
                                .partitionNumber(123)
                                .spreadDomain("spreadDomain")
                                .tenancy("tenancy")
                                .build())
                        .priority(123)
                        .subnetId("subnetId")
                        .weightedCapacity(123)
                        .build()))
                .build()))
        .targetCapacitySpecification(TargetCapacitySpecificationRequestProperty.builder()
                .totalTargetCapacity(123)

                // the properties below are optional
                .defaultTargetCapacityType("defaultTargetCapacityType")
                .onDemandTargetCapacity(123)
                .spotTargetCapacity(123)
                .targetCapacityUnitType("targetCapacityUnitType")
                .build())

        // the properties below are optional
        .context("context")
        .excessCapacityTerminationPolicy("excessCapacityTerminationPolicy")
        .onDemandOptions(OnDemandOptionsRequestProperty.builder()
                .allocationStrategy("allocationStrategy")
                .capacityReservationOptions(CapacityReservationOptionsRequestProperty.builder()
                        .usageStrategy("usageStrategy")
                        .build())
                .maxTotalPrice("maxTotalPrice")
                .minTargetCapacity(123)
                .singleAvailabilityZone(false)
                .singleInstanceType(false)
                .build())
        .replaceUnhealthyInstances(false)
        .reservedCapacityOptions(ReservedCapacityOptionsRequestProperty.builder()
                .allocationStrategy("allocationStrategy")
                .capacityReservationTarget(CapacityReservationTargetRequestProperty.builder()
                        .capacityReservationIds(List.of("capacityReservationIds"))
                        .capacityReservationResourceGroupArns(List.of("capacityReservationResourceGroupArns"))
                        .build())
                .reservationTypes(List.of("reservationTypes"))
                .reservedCapacityFallbackOptions(ReservedCapacityFallbackOptionsRequestProperty.builder()
                        .marketTypes(List.of("marketTypes"))
                        .build())
                .build())
        .spotOptions(SpotOptionsRequestProperty.builder()
                .allocationStrategy("allocationStrategy")
                .instanceInterruptionBehavior("instanceInterruptionBehavior")
                .instancePoolsToUseCount(123)
                .maintenanceStrategies(MaintenanceStrategiesProperty.builder()
                        .capacityRebalance(CapacityRebalanceProperty.builder()
                                .replacementStrategy("replacementStrategy")
                                .terminationDelay(123)
                                .build())
                        .build())
                .maxTotalPrice("maxTotalPrice")
                .minTargetCapacity(123)
                .singleAvailabilityZone(false)
                .singleInstanceType(false)
                .build())
        .tagSpecifications(List.of(TagSpecificationProperty.builder()
                .resourceType("resourceType")
                .tags(List.of(CfnTag.builder()
                        .key("key")
                        .value("value")
                        .build()))
                .build()))
        .terminateInstancesWithExpiration(false)
        .type("type")
        .validFrom("validFrom")
        .validUntil("validUntil")
        .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.EC2;

var cfnEC2Fleet = new CfnEC2Fleet(this, "MyCfnEC2Fleet", new CfnEC2FleetProps {
    LaunchTemplateConfigs = new [] { new FleetLaunchTemplateConfigRequestProperty {
        LaunchTemplateSpecification = new FleetLaunchTemplateSpecificationRequestProperty {
            Version = "version",

            // the properties below are optional
            LaunchTemplateId = "launchTemplateId",
            LaunchTemplateName = "launchTemplateName",
            LaunchTemplateSpecificationUserData = "launchTemplateSpecificationUserData"
        },
        Overrides = new [] { new FleetLaunchTemplateOverridesRequestProperty {
            AvailabilityZone = "availabilityZone",
            AvailabilityZoneId = "availabilityZoneId",
            BlockDeviceMappings = new [] { new BlockDeviceMappingProperty {
                DeviceName = "deviceName",
                Ebs = new EbsBlockDeviceProperty {
                    DeleteOnTermination = false,
                    Encrypted = false,
                    Iops = 123,
                    KmsKeyId = "kmsKeyId",
                    MultiAvailabilityZoneConfiguration = new MultiAvailabilityZoneConfigurationProperty {
                        ConfigurationType = "configurationType",
                        StandbyAvailabilityZones = new [] { new StandbyAvailabilityZoneProperty {
                            AvailabilityZone = "availabilityZone",
                            AvailabilityZoneId = "availabilityZoneId"
                        } }
                    },
                    SnapshotId = "snapshotId",
                    VolumeSize = 123,
                    VolumeType = "volumeType"
                },
                NoDevice = "noDevice",
                VirtualName = "virtualName"
            } },
            IamInstanceProfile = new IamInstanceProfileSpecificationProperty {
                Arn = "arn",
                Name = "name"
            },
            InstanceRequirements = new InstanceRequirementsRequestProperty {
                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
                },
                MemoryMiB = new MemoryMiBRequestProperty {
                    Max = 123,
                    Min = 123
                },
                NetworkBandwidthGbps = new NetworkBandwidthGbpsRequestProperty {
                    Max = 123,
                    Min = 123
                },
                NetworkInterfaceCount = new NetworkInterfaceCountRequestProperty {
                    Max = 123,
                    Min = 123
                },
                OnDemandMaxPricePercentageOverLowestPrice = 123,
                RequireEncryptionInTransit = false,
                RequireHibernateSupport = false,
                SpotMaxPricePercentageOverLowestPrice = 123,
                TotalLocalStorageGb = new TotalLocalStorageGBRequestProperty {
                    Max = 123,
                    Min = 123
                },
                VCpuCount = new VCpuCountRangeRequestProperty {
                    Max = 123,
                    Min = 123
                }
            },
            InstanceType = "instanceType",
            KeyName = "keyName",
            MaxPrice = "maxPrice",
            MetadataOptions = new InstanceMetadataOptionsRequestProperty {
                HttpEndpoint = "httpEndpoint",
                HttpPutResponseHopLimit = 123,
                HttpTokens = "httpTokens"
            },
            NetworkInterfaces = new [] { new NetworkInterfaceSpecificationRequestProperty {
                AssociatePublicIpAddress = false,
                DeleteOnTermination = false,
                Description = "description",
                DeviceIndex = 123,
                Groups = new [] { "groups" },
                InterfaceType = "interfaceType",
                Ipv6AddressCount = 123,
                Ipv6Addresses = new [] { new Ipv6AddressRequestProperty {
                    Ipv6Address = "ipv6Address"
                } },
                NetworkCardIndex = 123,
                NetworkInterfaceId = "networkInterfaceId",
                PrivateIpAddress = "privateIpAddress",
                PrivateIpAddresses = new [] { new PrivateIpAddressSpecificationRequestProperty {
                    Primary = false,
                    PrivateIpAddress = "privateIpAddress"
                } },
                SecondaryPrivateIpAddressCount = 123,
                SubnetId = "subnetId"
            } },
            Placement = new PlacementProperty {
                Affinity = "affinity",
                AvailabilityZone = "availabilityZone",
                GroupName = "groupName",
                HostId = "hostId",
                HostResourceGroupArn = "hostResourceGroupArn",
                PartitionNumber = 123,
                SpreadDomain = "spreadDomain",
                Tenancy = "tenancy"
            },
            Priority = 123,
            SubnetId = "subnetId",
            WeightedCapacity = 123
        } }
    } },
    TargetCapacitySpecification = new TargetCapacitySpecificationRequestProperty {
        TotalTargetCapacity = 123,

        // the properties below are optional
        DefaultTargetCapacityType = "defaultTargetCapacityType",
        OnDemandTargetCapacity = 123,
        SpotTargetCapacity = 123,
        TargetCapacityUnitType = "targetCapacityUnitType"
    },

    // the properties below are optional
    Context = "context",
    ExcessCapacityTerminationPolicy = "excessCapacityTerminationPolicy",
    OnDemandOptions = new OnDemandOptionsRequestProperty {
        AllocationStrategy = "allocationStrategy",
        CapacityReservationOptions = new CapacityReservationOptionsRequestProperty {
            UsageStrategy = "usageStrategy"
        },
        MaxTotalPrice = "maxTotalPrice",
        MinTargetCapacity = 123,
        SingleAvailabilityZone = false,
        SingleInstanceType = false
    },
    ReplaceUnhealthyInstances = false,
    ReservedCapacityOptions = new ReservedCapacityOptionsRequestProperty {
        AllocationStrategy = "allocationStrategy",
        CapacityReservationTarget = new CapacityReservationTargetRequestProperty {
            CapacityReservationIds = new [] { "capacityReservationIds" },
            CapacityReservationResourceGroupArns = new [] { "capacityReservationResourceGroupArns" }
        },
        ReservationTypes = new [] { "reservationTypes" },
        ReservedCapacityFallbackOptions = new ReservedCapacityFallbackOptionsRequestProperty {
            MarketTypes = new [] { "marketTypes" }
        }
    },
    SpotOptions = new SpotOptionsRequestProperty {
        AllocationStrategy = "allocationStrategy",
        InstanceInterruptionBehavior = "instanceInterruptionBehavior",
        InstancePoolsToUseCount = 123,
        MaintenanceStrategies = new MaintenanceStrategiesProperty {
            CapacityRebalance = new CapacityRebalanceProperty {
                ReplacementStrategy = "replacementStrategy",
                TerminationDelay = 123
            }
        },
        MaxTotalPrice = "maxTotalPrice",
        MinTargetCapacity = 123,
        SingleAvailabilityZone = false,
        SingleInstanceType = false
    },
    TagSpecifications = new [] { new TagSpecificationProperty {
        ResourceType = "resourceType",
        Tags = new [] { new CfnTag {
            Key = "key",
            Value = "value"
        } }
    } },
    TerminateInstancesWithExpiration = false,
    Type = "type",
    ValidFrom = "validFrom",
    ValidUntil = "validUntil"
});
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"

cfnEC2Fleet := awscdk.Aws_ec2.NewCfnEC2Fleet(this, jsii.String("MyCfnEC2Fleet"), &CfnEC2FleetProps{
	LaunchTemplateConfigs: []interface{}{
		&FleetLaunchTemplateConfigRequestProperty{
			LaunchTemplateSpecification: &FleetLaunchTemplateSpecificationRequestProperty{
				Version: jsii.String("version"),

				// the properties below are optional
				LaunchTemplateId: jsii.String("launchTemplateId"),
				LaunchTemplateName: jsii.String("launchTemplateName"),
				LaunchTemplateSpecificationUserData: jsii.String("launchTemplateSpecificationUserData"),
			},
			Overrides: []interface{}{
				&FleetLaunchTemplateOverridesRequestProperty{
					AvailabilityZone: jsii.String("availabilityZone"),
					AvailabilityZoneId: jsii.String("availabilityZoneId"),
					BlockDeviceMappings: []interface{}{
						&BlockDeviceMappingProperty{
							DeviceName: jsii.String("deviceName"),
							Ebs: &EbsBlockDeviceProperty{
								DeleteOnTermination: jsii.Boolean(false),
								Encrypted: jsii.Boolean(false),
								Iops: jsii.Number(123),
								KmsKeyId: jsii.String("kmsKeyId"),
								MultiAvailabilityZoneConfiguration: &MultiAvailabilityZoneConfigurationProperty{
									ConfigurationType: jsii.String("configurationType"),
									StandbyAvailabilityZones: []interface{}{
										&StandbyAvailabilityZoneProperty{
											AvailabilityZone: jsii.String("availabilityZone"),
											AvailabilityZoneId: jsii.String("availabilityZoneId"),
										},
									},
								},
								SnapshotId: jsii.String("snapshotId"),
								VolumeSize: jsii.Number(123),
								VolumeType: jsii.String("volumeType"),
							},
							NoDevice: jsii.String("noDevice"),
							VirtualName: jsii.String("virtualName"),
						},
					},
					IamInstanceProfile: &IamInstanceProfileSpecificationProperty{
						Arn: jsii.String("arn"),
						Name: jsii.String("name"),
					},
					InstanceRequirements: &InstanceRequirementsRequestProperty{
						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),
						},
						MemoryMiB: &MemoryMiBRequestProperty{
							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),
						RequireEncryptionInTransit: jsii.Boolean(false),
						RequireHibernateSupport: jsii.Boolean(false),
						SpotMaxPricePercentageOverLowestPrice: jsii.Number(123),
						TotalLocalStorageGb: &TotalLocalStorageGBRequestProperty{
							Max: jsii.Number(123),
							Min: jsii.Number(123),
						},
						VCpuCount: &VCpuCountRangeRequestProperty{
							Max: jsii.Number(123),
							Min: jsii.Number(123),
						},
					},
					InstanceType: jsii.String("instanceType"),
					KeyName: jsii.String("keyName"),
					MaxPrice: jsii.String("maxPrice"),
					MetadataOptions: &InstanceMetadataOptionsRequestProperty{
						HttpEndpoint: jsii.String("httpEndpoint"),
						HttpPutResponseHopLimit: jsii.Number(123),
						HttpTokens: jsii.String("httpTokens"),
					},
					NetworkInterfaces: []interface{}{
						&NetworkInterfaceSpecificationRequestProperty{
							AssociatePublicIpAddress: jsii.Boolean(false),
							DeleteOnTermination: jsii.Boolean(false),
							Description: jsii.String("description"),
							DeviceIndex: jsii.Number(123),
							Groups: []*string{
								jsii.String("groups"),
							},
							InterfaceType: jsii.String("interfaceType"),
							Ipv6AddressCount: jsii.Number(123),
							Ipv6Addresses: []interface{}{
								&Ipv6AddressRequestProperty{
									Ipv6Address: jsii.String("ipv6Address"),
								},
							},
							NetworkCardIndex: jsii.Number(123),
							NetworkInterfaceId: jsii.String("networkInterfaceId"),
							PrivateIpAddress: jsii.String("privateIpAddress"),
							PrivateIpAddresses: []interface{}{
								&PrivateIpAddressSpecificationRequestProperty{
									Primary: jsii.Boolean(false),
									PrivateIpAddress: jsii.String("privateIpAddress"),
								},
							},
							SecondaryPrivateIpAddressCount: jsii.Number(123),
							SubnetId: jsii.String("subnetId"),
						},
					},
					Placement: &PlacementProperty{
						Affinity: jsii.String("affinity"),
						AvailabilityZone: jsii.String("availabilityZone"),
						GroupName: jsii.String("groupName"),
						HostId: jsii.String("hostId"),
						HostResourceGroupArn: jsii.String("hostResourceGroupArn"),
						PartitionNumber: jsii.Number(123),
						SpreadDomain: jsii.String("spreadDomain"),
						Tenancy: jsii.String("tenancy"),
					},
					Priority: jsii.Number(123),
					SubnetId: jsii.String("subnetId"),
					WeightedCapacity: jsii.Number(123),
				},
			},
		},
	},
	TargetCapacitySpecification: &TargetCapacitySpecificationRequestProperty{
		TotalTargetCapacity: jsii.Number(123),

		// the properties below are optional
		DefaultTargetCapacityType: jsii.String("defaultTargetCapacityType"),
		OnDemandTargetCapacity: jsii.Number(123),
		SpotTargetCapacity: jsii.Number(123),
		TargetCapacityUnitType: jsii.String("targetCapacityUnitType"),
	},

	// the properties below are optional
	Context: jsii.String("context"),
	ExcessCapacityTerminationPolicy: jsii.String("excessCapacityTerminationPolicy"),
	OnDemandOptions: &OnDemandOptionsRequestProperty{
		AllocationStrategy: jsii.String("allocationStrategy"),
		CapacityReservationOptions: &CapacityReservationOptionsRequestProperty{
			UsageStrategy: jsii.String("usageStrategy"),
		},
		MaxTotalPrice: jsii.String("maxTotalPrice"),
		MinTargetCapacity: jsii.Number(123),
		SingleAvailabilityZone: jsii.Boolean(false),
		SingleInstanceType: jsii.Boolean(false),
	},
	ReplaceUnhealthyInstances: jsii.Boolean(false),
	ReservedCapacityOptions: &ReservedCapacityOptionsRequestProperty{
		AllocationStrategy: jsii.String("allocationStrategy"),
		CapacityReservationTarget: &CapacityReservationTargetRequestProperty{
			CapacityReservationIds: []*string{
				jsii.String("capacityReservationIds"),
			},
			CapacityReservationResourceGroupArns: []*string{
				jsii.String("capacityReservationResourceGroupArns"),
			},
		},
		ReservationTypes: []*string{
			jsii.String("reservationTypes"),
		},
		ReservedCapacityFallbackOptions: &ReservedCapacityFallbackOptionsRequestProperty{
			MarketTypes: []*string{
				jsii.String("marketTypes"),
			},
		},
	},
	SpotOptions: &SpotOptionsRequestProperty{
		AllocationStrategy: jsii.String("allocationStrategy"),
		InstanceInterruptionBehavior: jsii.String("instanceInterruptionBehavior"),
		InstancePoolsToUseCount: jsii.Number(123),
		MaintenanceStrategies: &MaintenanceStrategiesProperty{
			CapacityRebalance: &CapacityRebalanceProperty{
				ReplacementStrategy: jsii.String("replacementStrategy"),
				TerminationDelay: jsii.Number(123),
			},
		},
		MaxTotalPrice: jsii.String("maxTotalPrice"),
		MinTargetCapacity: jsii.Number(123),
		SingleAvailabilityZone: jsii.Boolean(false),
		SingleInstanceType: jsii.Boolean(false),
	},
	TagSpecifications: []interface{}{
		&TagSpecificationProperty{
			ResourceType: jsii.String("resourceType"),
			Tags: []CfnTag{
				&CfnTag{
					Key: jsii.String("key"),
					Value: jsii.String("value"),
				},
			},
		},
	},
	TerminateInstancesWithExpiration: jsii.Boolean(false),
	Type: jsii.String("type"),
	ValidFrom: jsii.String("validFrom"),
	ValidUntil: jsii.String("validUntil"),
})

Initializer ​

ts
new CfnEC2Fleet(scope: Construct, id: string, props: CfnEC2FleetProps)
python
CfnEC2Fleet(scope: Construct, id: str, props: CfnEC2FleetProps)
java
new CfnEC2Fleet(Construct scope, String id, CfnEC2FleetProps props)
csharp
new CfnEC2Fleet(Construct scope, string id, CfnEC2FleetProps props)
go
NewCfnEC2Fleet(Scope Construct, Id *string, Props CfnEC2FleetProps)

Construct Props ​

contextoptionalstringcontextoptionalstrcontextoptionalStringContextoptionalstringContextoptional*string#
Reserved.
excessCapacityTerminationPolicyoptionalstringexcess_capacity_termination_policyoptionalstrexcessCapacityTerminationPolicyoptionalStringExcessCapacityTerminationPolicyoptionalstringExcessCapacityTerminationPolicyoptional*string#
Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is decreased below the current size of the EC2 Fleet.

Supported only for fleets of type maintain .

launchTemplateConfigsIResolvable | IResolvable | CfnEC2Fleet.FleetLaunchTemplateConfigRequestProperty[]launch_template_configstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, FleetLaunchTemplateConfigRequestProperty]]]launchTemplateConfigsIResolvableLaunchTemplateConfigsIResolvableLaunchTemplateConfigsinterface{}required#
The configuration for the EC2 Fleet.
onDemandOptionsoptionalIResolvable | CfnEC2Fleet.OnDemandOptionsRequestPropertyon_demand_optionsoptionaltyping.Union[IResolvable, OnDemandOptionsRequestProperty]onDemandOptionsoptionalIResolvableOnDemandOptionsoptionalIResolvableOnDemandOptionsoptionalinterface{}#
Describes the configuration of On-Demand Instances in an EC2 Fleet.
replaceUnhealthyInstancesoptionalboolean | IResolvablereplace_unhealthy_instancesoptionaltyping.Union[bool, IResolvable]replaceUnhealthyInstancesoptionalBooleanReplaceUnhealthyInstancesoptionalboolReplaceUnhealthyInstancesoptionalinterface{}#
Indicates whether EC2 Fleet should replace unhealthy Spot Instances.

Supported only for fleets of type maintain . For more information, see EC2 Fleet health checks in the Amazon EC2 User Guide .

reservedCapacityOptionsoptionalIResolvable | CfnEC2Fleet.ReservedCapacityOptionsRequestPropertyreserved_capacity_optionsoptionaltyping.Union[IResolvable, ReservedCapacityOptionsRequestProperty]reservedCapacityOptionsoptionalIResolvableReservedCapacityOptionsoptionalIResolvableReservedCapacityOptionsoptionalinterface{}#
spotOptionsoptionalIResolvable | CfnEC2Fleet.SpotOptionsRequestPropertyspot_optionsoptionaltyping.Union[IResolvable, SpotOptionsRequestProperty]spotOptionsoptionalIResolvableSpotOptionsoptionalIResolvableSpotOptionsoptionalinterface{}#
Describes the configuration of Spot Instances in an EC2 Fleet.
tagSpecificationsoptionalIResolvable | IResolvable | CfnEC2Fleet.TagSpecificationProperty[]tag_specificationsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, TagSpecificationProperty]]]tagSpecificationsoptionalIResolvableTagSpecificationsoptionalIResolvableTagSpecificationsoptionalinterface{}#
The key-value pair for tagging the EC2 Fleet request on creation. For more information, see [Tag your resources](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#tag-resources) .
notes

If the fleet type is instant , specify a resource type of fleet to tag the fleet or instance to tag the instances at launch.

If the fleet type is maintain or request , specify a resource type of fleet to tag the fleet. You cannot specify a resource type of instance . To tag instances at launch, specify the tags in a launch template .

targetCapacitySpecificationIResolvable | CfnEC2Fleet.TargetCapacitySpecificationRequestPropertytarget_capacity_specificationtyping.Union[IResolvable, TargetCapacitySpecificationRequestProperty]targetCapacitySpecificationIResolvableTargetCapacitySpecificationIResolvableTargetCapacitySpecificationinterface{}required#
The number of units to request.
terminateInstancesWithExpirationoptionalboolean | IResolvableterminate_instances_with_expirationoptionaltyping.Union[bool, IResolvable]terminateInstancesWithExpirationoptionalBooleanTerminateInstancesWithExpirationoptionalboolTerminateInstancesWithExpirationoptionalinterface{}#
Indicates whether running instances should be terminated when the EC2 Fleet expires.
typeoptionalstringtypeoptionalstrtypeoptionalStringTypeoptionalstringTypeoptional*string#
The fleet type. The default value is `maintain` .
notes
  • maintain - The EC2 Fleet places an asynchronous request for your desired capacity, and continues to maintain your desired Spot capacity by replenishing interrupted Spot Instances.
  • request - The EC2 Fleet places an asynchronous one-time request for your desired capacity, but does submit Spot requests in alternative capacity pools if Spot capacity is unavailable, and does not maintain Spot capacity if Spot Instances are interrupted.
  • instant - The EC2 Fleet places a synchronous one-time request for your desired capacity, and returns errors for any instances that could not be launched.

For more information, see EC2 Fleet request types in the Amazon EC2 User Guide .

validFromoptionalstringvalid_fromoptionalstrvalidFromoptionalStringValidFromoptionalstringValidFromoptional*string#
The start date and time of the request, in UTC format (for example, *YYYY* - *MM* - *DD* T *HH* : *MM* : *SS* Z).

The default is to start fulfilling the request immediately.

validUntiloptionalstringvalid_untiloptionalstrvalidUntiloptionalStringValidUntiloptionalstringValidUntiloptional*string#
The end date and time of the request, in UTC format (for example, *YYYY* - *MM* - *DD* T *HH* : *MM* : *SS* Z).

At this point, no new EC2 Fleet requests are placed or able to fulfill the request. If no value is specified, the request remains until you cancel it.

Properties ​

attrFleetIdstringattr_fleet_idstrattrFleetIdStringAttrFleetIdstringAttrFleetId*stringrequired#
The ID of the EC2 Fleet.
CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringrequiredstatic#
The CloudFormation resource type name for this resource class.
Options for this resource, such as condition, update policy etc.
cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*stringrequired#
AWS resource type.
contextmay be undefinedstringcontextmay be undefinedstrcontextmay be undefinedStringContextmay be undefinedstringContextmay be undefined*string#
Reserved.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#
ec2FleetRefEC2FleetReferenceec2_fleet_refEC2FleetReferenceec2FleetRefEC2FleetReferenceEc2FleetRefEC2FleetReferenceEc2FleetRefEC2FleetReferencerequired#
A reference to a EC2Fleet resource.
excessCapacityTerminationPolicymay be undefinedstringexcess_capacity_termination_policymay be undefinedstrexcessCapacityTerminationPolicymay be undefinedStringExcessCapacityTerminationPolicymay be undefinedstringExcessCapacityTerminationPolicymay be undefined*string#
Indicates whether running instances should be terminated if the total target capacity of the EC2 Fleet is decreased below the current size of the EC2 Fleet.
launchTemplateConfigsIResolvable | IResolvable | CfnEC2Fleet.FleetLaunchTemplateConfigRequestProperty[]launch_template_configstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, FleetLaunchTemplateConfigRequestProperty]]]launchTemplateConfigsIResolvableLaunchTemplateConfigsIResolvableLaunchTemplateConfigsinterface{}required#
The configuration for the EC2 Fleet.
logicalIdstringlogical_idstrlogicalIdStringLogicalIdstringLogicalId*stringrequired#
The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
onDemandOptionsmay be undefinedIResolvable | CfnEC2Fleet.OnDemandOptionsRequestPropertyon_demand_optionsmay be undefinedtyping.Union[IResolvable, OnDemandOptionsRequestProperty]onDemandOptionsmay be undefinedIResolvableOnDemandOptionsmay be undefinedIResolvableOnDemandOptionsmay be undefinedinterface{}#
Describes the configuration of On-Demand Instances in an EC2 Fleet.
refstringrefstrrefStringRefstringRef*stringrequired#
Return a string that will be resolved to a CloudFormation `{ Ref }` for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

replaceUnhealthyInstancesmay be undefinedboolean | IResolvablereplace_unhealthy_instancesmay be undefinedtyping.Union[bool, IResolvable]replaceUnhealthyInstancesmay be undefinedBooleanReplaceUnhealthyInstancesmay be undefinedboolReplaceUnhealthyInstancesmay be undefinedinterface{}#
Indicates whether EC2 Fleet should replace unhealthy Spot Instances.
reservedCapacityOptionsmay be undefinedIResolvable | CfnEC2Fleet.ReservedCapacityOptionsRequestPropertyreserved_capacity_optionsmay be undefinedtyping.Union[IResolvable, ReservedCapacityOptionsRequestProperty]reservedCapacityOptionsmay be undefinedIResolvableReservedCapacityOptionsmay be undefinedIResolvableReservedCapacityOptionsmay be undefinedinterface{}#
spotOptionsmay be undefinedIResolvable | CfnEC2Fleet.SpotOptionsRequestPropertyspot_optionsmay be undefinedtyping.Union[IResolvable, SpotOptionsRequestProperty]spotOptionsmay be undefinedIResolvableSpotOptionsmay be undefinedIResolvableSpotOptionsmay be undefinedinterface{}#
Describes the configuration of Spot Instances in an EC2 Fleet.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

tagSpecificationsmay be undefinedIResolvable | IResolvable | CfnEC2Fleet.TagSpecificationProperty[]tag_specificationsmay be undefinedtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, TagSpecificationProperty]]]tagSpecificationsmay be undefinedIResolvableTagSpecificationsmay be undefinedIResolvableTagSpecificationsmay be undefinedinterface{}#
The key-value pair for tagging the EC2 Fleet request on creation.

For more information, see Tag your resources .

targetCapacitySpecificationIResolvable | CfnEC2Fleet.TargetCapacitySpecificationRequestPropertytarget_capacity_specificationtyping.Union[IResolvable, TargetCapacitySpecificationRequestProperty]targetCapacitySpecificationIResolvableTargetCapacitySpecificationIResolvableTargetCapacitySpecificationinterface{}required#
The number of units to request.
terminateInstancesWithExpirationmay be undefinedboolean | IResolvableterminate_instances_with_expirationmay be undefinedtyping.Union[bool, IResolvable]terminateInstancesWithExpirationmay be undefinedBooleanTerminateInstancesWithExpirationmay be undefinedboolTerminateInstancesWithExpirationmay be undefinedinterface{}#
Indicates whether running instances should be terminated when the EC2 Fleet expires.
typemay be undefinedstringtypemay be undefinedstrtypemay be undefinedStringTypemay be undefinedstringTypemay be undefined*string#
The fleet type.

The default value is maintain .

validFrommay be undefinedstringvalid_frommay be undefinedstrvalidFrommay be undefinedStringValidFrommay be undefinedstringValidFrommay be undefined*string#
The start date and time of the request, in UTC format (for example, *YYYY* - *MM* - *DD* T *HH* : *MM* : *SS* Z).
validUntilmay be undefinedstringvalid_untilmay be undefinedstrvalidUntilmay be undefinedStringValidUntilmay be undefinedstringValidUntilmay be undefined*string#
The end date and time of the request, in UTC format (for example, *YYYY* - *MM* - *DD* T *HH* : *MM* : *SS* Z).

Methods ​

addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#
Syntactic sugar for `addOverride(path, undefined)`.
1 parameter

Parameters

  • pathpathpathpathPath — The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#
Use `addResourceDependency` instead.

This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.

addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#
Use `addResourceDependency` instead.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.

addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#
Add a value to the CloudFormation Resource Metadata.
addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#
Adds an override to the synthesized CloudFormation resource.
notes · 2 parameters

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

typescript
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

json
"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters

  • pathpathpathpathPath — - The path of the property, you can use dot notation to override values in complex types.
  • valuevaluevaluevalueValue — - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#
Adds an override that deletes the value of a property from the resource definition.
1 parameter

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#
Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

2 parameters

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path of the property.
  • valuevaluevaluevalueValue — The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Sets the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.

1 parameter

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#
Sets the deletion policy of the resource based on the removal policy specified.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

arnForEC2Fleet(resource: IEC2FleetRef): string@staticmethod def arn_for_ec2_fleet(resource: IEC2FleetRef) -> strpublic static String arnForEC2Fleet(IEC2FleetRef resource)public static string ArnForEC2Fleet(IEC2FleetRef resource)func ArnForEC2Fleet(Resource IEC2FleetRef) *stringstatic#
cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#
fromFleetId(scope: Construct, id: string, fleetId: string): IEC2FleetRef@staticmethod def from_fleet_id(scope: Construct, id: str, fleet_id: str) -> IEC2FleetRefpublic static IEC2FleetRef fromFleetId(Construct scope, String id, String fleetId)public static IEC2FleetRef FromFleetId(Construct scope, string id, string fleetId)func FromFleetId(Scope Construct, Id *string, FleetId *string) IEC2FleetRefstatic#
Creates a new IEC2FleetRef from a fleetId.
getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#
Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

1 parameter

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#
Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#
Examines the CloudFormation resource and discloses attributes.
1 parameter

Parameters

  • inspectorinspectorinspectorinspectorInspector — tree inspector to collect and process attributes.
isCfnEC2Fleet(x: any): boolean@staticmethod def is_cfn_ec2_fleet(x: Any) -> boolpublic static Boolean isCfnEC2Fleet(Object x)public static bool IsCfnEC2Fleet(object x)func IsCfnEC2Fleet(X interface{}) *boolstatic#
Checks whether the given object is a CfnEC2Fleet.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#
Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

returns

Returns: The construct as a stack element or undefined if it is not a stack element.

isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#
Check whether the given object is a CfnResource.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#
Retrieves an array of resources and stacks this resource depends on.

For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.

overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#
Overrides the auto-generated logical ID with a specific ID.
1 parameter

Parameters

  • newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId — The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#
Use `removeResourceDependency` instead

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#
Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#
Replaces one dependency with another.
2 parameters

Parameters

  • targettargettargettargetTarget — The dependency to replace.
  • newTargetnew_targetnewTargetnewTargetNewTarget — The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
returns

Returns: a string representation of this resource

with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.