@wheatstalk/fargate-spot-fallback

A CDK construct that brings a fallback ECS service online when ECS cannnot acquire Fargate spot capacity.

Showing:

Popularity

Downloads/wk

169

GitHub Stars

6

Maintenance

Last Commit

3d ago

Contributors

3

Package

Dependencies

8

License

Apache-2.0

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

Fargate Spot Fallback Construct

Release npm

This construct links a fallback ECS service to your Fargate Spot service so that if ECS cannot acquire any Fargate Spot capacity, the fallback service's desiredCount is increased to your primary service's desired count. When your primary service returns to a steady state, the construct will return the fallback service to zero desired count.

Example

// Define your task
const taskDefinition = new ecs.FargateTaskDefinition(this, 'Primary');
taskDefinition.addContainer('web', {
  image: ecs.ContainerImage.fromRegistry('nginx:1'),
  portMappings: [{ containerPort: 80 }],
});

// Create your primary service with Fargate Spot
const primaryService = new ecs.FargateService(this, 'PrimaryService', {
  cluster,
  taskDefinition,
  capacityProviderStrategies: [{ capacityProvider: 'FARGATE_SPOT', weight: 1 }],
  desiredCount: 10,
});

// Create a fallback service with on-demand Fargate and a desired count of
// zero. This service should be the same as your primary service, except
// with a different capacity provider and an initial desired count of zero.
const fallbackService = new ecs.FargateService(this, 'FallbackService', {
  cluster,
  taskDefinition,
  capacityProviderStrategies: [{ capacityProvider: 'FARGATE', weight: 1 }],
});

// Create the fallback policy which increases the fallback service's desired
// count when the primary service can't provision tasks.
const policy = new FallbackPolicy(this, 'FallbackPolicy', {
  primaryService,
  fallbackService,
});

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100