By using AWS re:Post, you agree to the Terms of Use

Questions tagged with EC2 Fleet

Sort by most recent
  • 1
  • 2
  • 12 / page

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Run fleet with on demand instance across AZ

Hello, I wanted to start EC2 fleet with on-demand instances only, and I wanted them to be distributed across availability zones. Unfortunately, I couldn't find a way to do that, and all the instances are always started in a single AZ. That is not a problem with spot instances, as they spawn in all the AZ. I was trying to try different allocation strategies and priorities, but nothing helped. I was trying to do so in AWS-CDK, using both `CfnEC2Fleet` [link](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnEC2Fleet.html) as well as `CfnSpotFleet` [link](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.CfnSpotFleet.html). Bellow is my code. Is there way how to achieve that, or do I need to use something else? Thank you. ```typescript const spotFleet = new CfnSpotFleet(stack, 'EC2-Fleet', { spotFleetRequestConfigData: { allocationStrategy: 'lowestPrice', targetCapacity: 8, iamFleetRole: fleetRole.roleArn, spotMaintenanceStrategies: { capacityRebalance: { replacementStrategy: 'launch-before-terminate', terminationDelay: 120, } }, onDemandTargetCapacity: 4, instancePoolsToUseCount: stack.availabilityZones.length, launchTemplateConfigs: [{ launchTemplateSpecification: { launchTemplateId: launchTemplate.launchTemplateId, version: launchTemplate.latestVersionNumber, }, overrides: privateSubnets.map(subnet => ({ availabilityZone: subnet.subnetAvailabilityZone, subnetId: subnet.subnetId, })), }], } }); const ec2Fleet = new CfnEC2Fleet(stack, 'EC2-EcFleet', { targetCapacitySpecification: { totalTargetCapacity: 6, onDemandTargetCapacity: 6, defaultTargetCapacityType: 'on-demand', }, replaceUnhealthyInstances: true, onDemandOptions: { allocationStrategy: 'prioritized', }, launchTemplateConfigs: [{ launchTemplateSpecification: { launchTemplateId: launchTemplate.launchTemplateId, version: launchTemplate.latestVersionNumber, }, overrides: privateSubnets.map(subnet => ({ availabilityZone: subnet.subnetAvailabilityZone, subnetId: subnet.subnetId, })), }] }); ``` Where `launchTemplate` is instance of [`LaunchTemplate`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.LaunchTemplate.html) and `privateSubnets` is array of [`Subnet`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Subnet.html) instances, one for each AZ.
0
answers
0
votes
50
views
asked 5 months ago
  • 1
  • 2
  • 12 / page