Skip to content
v2.278.0

SpotAllocationStrategy Enum ​

Spot Allocation Strategies.

Specifies the strategy to use in launching Spot Instance fleets. For example, "capacity-optimized" launches instances from Spot Instance pools with optimal capacity for the number of instances that are launching.

Example ​

ts
new tasks.EmrCreateCluster(this, 'OnDemandSpecification', {
  instances: {
    instanceFleets: [{
      instanceFleetType: tasks.EmrCreateCluster.InstanceRoleType.MASTER,
      launchSpecifications: {
        onDemandSpecification: {
          allocationStrategy: tasks.EmrCreateCluster.OnDemandAllocationStrategy.LOWEST_PRICE,
        },
      },
    }],
  },
  name: 'OnDemandCluster',
  integrationPattern: sfn.IntegrationPattern.RUN_JOB,
});

new tasks.EmrCreateCluster(this, 'SpotSpecification', {
  instances: {
    instanceFleets: [{
      instanceFleetType: tasks.EmrCreateCluster.InstanceRoleType.MASTER,
      launchSpecifications: {
        spotSpecification: {
          allocationStrategy: tasks.EmrCreateCluster.SpotAllocationStrategy.CAPACITY_OPTIMIZED,
          timeoutAction: tasks.EmrCreateCluster.SpotTimeoutAction.TERMINATE_CLUSTER,
          timeout: Duration.minutes(5),
        },
      },
    }],
  },
  name: 'SpotCluster',
  integrationPattern: sfn.IntegrationPattern.RUN_JOB,
});
python
tasks.EmrCreateCluster(self, "OnDemandSpecification",
    instances=tasks.EmrCreateCluster.InstancesConfigProperty(
        instance_fleets=[tasks.EmrCreateCluster.InstanceFleetConfigProperty(
            instance_fleet_type=tasks.EmrCreateCluster.InstanceRoleType.MASTER,
            launch_specifications=tasks.EmrCreateCluster.InstanceFleetProvisioningSpecificationsProperty(
                on_demand_specification=tasks.EmrCreateCluster.OnDemandProvisioningSpecificationProperty(
                    allocation_strategy=tasks.EmrCreateCluster.OnDemandAllocationStrategy.LOWEST_PRICE
                )
            )
        )]
    ),
    name="OnDemandCluster",
    integration_pattern=sfn.IntegrationPattern.RUN_JOB
)

tasks.EmrCreateCluster(self, "SpotSpecification",
    instances=tasks.EmrCreateCluster.InstancesConfigProperty(
        instance_fleets=[tasks.EmrCreateCluster.InstanceFleetConfigProperty(
            instance_fleet_type=tasks.EmrCreateCluster.InstanceRoleType.MASTER,
            launch_specifications=tasks.EmrCreateCluster.InstanceFleetProvisioningSpecificationsProperty(
                spot_specification=tasks.EmrCreateCluster.SpotProvisioningSpecificationProperty(
                    allocation_strategy=tasks.EmrCreateCluster.SpotAllocationStrategy.CAPACITY_OPTIMIZED,
                    timeout_action=tasks.EmrCreateCluster.SpotTimeoutAction.TERMINATE_CLUSTER,
                    timeout=Duration.minutes(5)
                )
            )
        )]
    ),
    name="SpotCluster",
    integration_pattern=sfn.IntegrationPattern.RUN_JOB
)
java
EmrCreateCluster.Builder.create(this, "OnDemandSpecification")
        .instances(InstancesConfigProperty.builder()
                .instanceFleets(List.of(InstanceFleetConfigProperty.builder()
                        .instanceFleetType(EmrCreateCluster.getInstanceRoleType().MASTER)
                        .launchSpecifications(InstanceFleetProvisioningSpecificationsProperty.builder()
                                .onDemandSpecification(OnDemandProvisioningSpecificationProperty.builder()
                                        .allocationStrategy(EmrCreateCluster.getOnDemandAllocationStrategy().LOWEST_PRICE)
                                        .build())
                                .build())
                        .build()))
                .build())
        .name("OnDemandCluster")
        .integrationPattern(IntegrationPattern.RUN_JOB)
        .build();

EmrCreateCluster.Builder.create(this, "SpotSpecification")
        .instances(InstancesConfigProperty.builder()
                .instanceFleets(List.of(InstanceFleetConfigProperty.builder()
                        .instanceFleetType(EmrCreateCluster.getInstanceRoleType().MASTER)
                        .launchSpecifications(InstanceFleetProvisioningSpecificationsProperty.builder()
                                .spotSpecification(SpotProvisioningSpecificationProperty.builder()
                                        .allocationStrategy(EmrCreateCluster.getSpotAllocationStrategy().CAPACITY_OPTIMIZED)
                                        .timeoutAction(EmrCreateCluster.getSpotTimeoutAction().TERMINATE_CLUSTER)
                                        .timeout(Duration.minutes(5))
                                        .build())
                                .build())
                        .build()))
                .build())
        .name("SpotCluster")
        .integrationPattern(IntegrationPattern.RUN_JOB)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new EmrCreateCluster(this, "OnDemandSpecification", new EmrCreateClusterProps {
    Instances = new InstancesConfigProperty {
        InstanceFleets = new [] { new InstanceFleetConfigProperty {
            InstanceFleetType = EmrCreateCluster.InstanceRoleType.MASTER,
            LaunchSpecifications = new InstanceFleetProvisioningSpecificationsProperty {
                OnDemandSpecification = new OnDemandProvisioningSpecificationProperty {
                    AllocationStrategy = EmrCreateCluster.OnDemandAllocationStrategy.LOWEST_PRICE
                }
            }
        } }
    },
    Name = "OnDemandCluster",
    IntegrationPattern = IntegrationPattern.RUN_JOB
});

new EmrCreateCluster(this, "SpotSpecification", new EmrCreateClusterProps {
    Instances = new InstancesConfigProperty {
        InstanceFleets = new [] { new InstanceFleetConfigProperty {
            InstanceFleetType = EmrCreateCluster.InstanceRoleType.MASTER,
            LaunchSpecifications = new InstanceFleetProvisioningSpecificationsProperty {
                SpotSpecification = new SpotProvisioningSpecificationProperty {
                    AllocationStrategy = EmrCreateCluster.SpotAllocationStrategy.CAPACITY_OPTIMIZED,
                    TimeoutAction = EmrCreateCluster.SpotTimeoutAction.TERMINATE_CLUSTER,
                    Timeout = Duration.Minutes(5)
                }
            }
        } }
    },
    Name = "SpotCluster",
    IntegrationPattern = IntegrationPattern.RUN_JOB
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
tasks.NewEmrCreateCluster(this, jsii.String("OnDemandSpecification"), &EmrCreateClusterProps{
	Instances: &InstancesConfigProperty{
		InstanceFleets: []InstanceFleetConfigProperty{
			&InstanceFleetConfigProperty{
				InstanceFleetType: tasks.EmrCreateCluster.InstanceRoleType_MASTER,
				LaunchSpecifications: &InstanceFleetProvisioningSpecificationsProperty{
					OnDemandSpecification: &OnDemandProvisioningSpecificationProperty{
						AllocationStrategy: tasks.EmrCreateCluster.OnDemandAllocationStrategy_LOWEST_PRICE,
					},
				},
			},
		},
	},
	Name: jsii.String("OnDemandCluster"),
	IntegrationPattern: sfn.IntegrationPattern_RUN_JOB,
})

tasks.NewEmrCreateCluster(this, jsii.String("SpotSpecification"), &EmrCreateClusterProps{
	Instances: &InstancesConfigProperty{
		InstanceFleets: []InstanceFleetConfigProperty{
			&InstanceFleetConfigProperty{
				InstanceFleetType: tasks.EmrCreateCluster.InstanceRoleType_MASTER,
				LaunchSpecifications: &InstanceFleetProvisioningSpecificationsProperty{
					SpotSpecification: &SpotProvisioningSpecificationProperty{
						AllocationStrategy: tasks.EmrCreateCluster.SpotAllocationStrategy_CAPACITY_OPTIMIZED,
						TimeoutAction: tasks.EmrCreateCluster.SpotTimeoutAction_TERMINATE_CLUSTER,
						Timeout: awscdk.Duration_Minutes(jsii.Number(5)),
					},
				},
			},
		},
	},
	Name: jsii.String("SpotCluster"),
	IntegrationPattern: sfn.IntegrationPattern_RUN_JOB,
})

Members ​

MemberDescription
CAPACITY_OPTIMIZEDCapacity-optimized, which launches instances from Spot Instance pools with optimal capacity for the number of instances that are launching.
PRICE_CAPACITY_OPTIMIZEDPrice-capacity-optimized, which launches instances from Spot Instance pools with the highest capacity availability for the number of instances that are launching.
LOWEST_PRICELowest-price, which launches instances from the lowest priced pool that has available capacity.
DIVERSIFIEDDiversified, which launches instances across all Spot capacity pools.

Referenced by ​