Skip to content
GitHubXDiscord

SchedulingPolicy

The SchedulingPolicy resource allows you to manage the scheduling policies for AWS Batch jobs, which define how jobs are scheduled and prioritized within the Batch environment. For more information, visit the AWS Batch SchedulingPolicys documentation.

Create a basic scheduling policy with a fair share policy:

import AWS from "alchemy/aws/control";
const minimalSchedulingPolicy = await AWS.Batch.SchedulingPolicy("minimalSchedulingPolicy", {
Name: "MinimalSchedulingPolicy",
FairsharePolicy: {
ShareDecaySeconds: 86400,
ComputeEnvironments: [
{
ComputeEnvironment: "exampleComputeEnv",
Share: 100
}
]
},
Tags: {
Environment: "Development",
Team: "Batch"
}
});

Configure a scheduling policy with more complex fair share settings:

const advancedSchedulingPolicy = await AWS.Batch.SchedulingPolicy("advancedSchedulingPolicy", {
Name: "AdvancedSchedulingPolicy",
FairsharePolicy: {
ShareDecaySeconds: 3600,
ComputeEnvironments: [
{
ComputeEnvironment: "exampleComputeEnv1",
Share: 70
},
{
ComputeEnvironment: "exampleComputeEnv2",
Share: 30
}
]
},
Tags: {
Environment: "Production",
Team: "Batch"
}
});

Create a scheduling policy specifically for a team with detailed tags:

const teamSchedulingPolicy = await AWS.Batch.SchedulingPolicy("teamSchedulingPolicy", {
Name: "TeamSchedulingPolicy",
FairsharePolicy: {
ShareDecaySeconds: 7200,
ComputeEnvironments: [
{
ComputeEnvironment: "teamComputeEnv",
Share: 50
}
]
},
Tags: {
Project: "DataProcessing",
Owner: "DataTeam",
Purpose: "BatchJobScheduling"
}
});

Create a scheduling policy that adopts an existing resource if it already exists:

const adoptSchedulingPolicy = await AWS.Batch.SchedulingPolicy("adoptSchedulingPolicy", {
Name: "AdoptSchedulingPolicy",
FairsharePolicy: {
ShareDecaySeconds: 43200,
ComputeEnvironments: [
{
ComputeEnvironment: "adoptComputeEnv",
Share: 100
}
]
},
Tags: {
Environment: "Testing"
},
adopt: true // Enable adoption of existing resource
});