Aws batch : choose compute environnement on launch

Viewed 35

I have a aws cloudformation template for my batch definition. I have 2 compute environnement définition, a on demand and a spot.

DragenComputeEnvironmentSpot:
    Type: AWS::Batch::ComputeEnvironment
    Properties:
      ComputeEnvironmentName: dragen-spot
      ServiceRole: !Ref BatchServiceRole
      Type: MANAGED
      State: ENABLED
      ComputeResources:
        BidPercentage: !Ref BidPercentage
        Ec2KeyPair: !Ref Ec2KeyPair
        ImageId: !Ref ImageId
        InstanceRole: !Ref DragenInstanceRole
        InstanceTypes: [!Ref InstanceType]
        MinvCpus: !Ref MinvCpus
        DesiredvCpus: !Ref DesiredvCpus
        MaxvCpus: !Ref MaxvCpus
        SecurityGroupIds:
        - !Ref BatchSecurityGroup
        SpotIamFleetRole: !Ref SpotFleetRole
        Subnets: !Ref SubnetIds
        Type: SPOT
        LaunchTemplate:
          LaunchTemplateId: !Ref DragenLaunchTemplate
  DragenComputeEnvironmentOnDemand:
    Type: AWS::Batch::ComputeEnvironment
    Properties:
      ComputeEnvironmentName: dragen-ondemand
      ServiceRole: !Ref BatchServiceRole
      Type: MANAGED
      State: ENABLED
      ComputeResources:
        Ec2KeyPair: !Ref Ec2KeyPair
        ImageId: !Ref ImageId
        InstanceRole: !Ref DragenInstanceRole
        InstanceTypes: [!Ref InstanceType]
        MinvCpus: !Ref MinvCpus
        DesiredvCpus: !Ref DesiredvCpus
        MaxvCpus: !Ref MaxvCpus
        SecurityGroupIds:
        - !Ref BatchSecurityGroup
        Subnets: !Ref SubnetIds
        Type: EC2
        LaunchTemplate:
          LaunchTemplateId: !Ref DragenLaunchTemplate

Then in the jobqueue définition i have :

DragenJobQueue:
    Type: AWS::Batch::JobQueue
    Properties:
      JobQueueName: dragen-queue
      Priority: 100
      State: ENABLED
      ComputeEnvironmentOrder:
        - Order: 1
          ComputeEnvironment: !Ref DragenComputeEnvironmentOnDemand
        - Order: 2
          ComputeEnvironment: !Ref DragenComputeEnvironmentSpot

So if i understand well the on demand has the priority (so spot will never be use). But i would like to know if there is a way to override during the job launch ? Some job fit well with on demand but others are better on spot.

0 Answers
Related