Skip to content

(aws-ecs-patterns): add support for Fargate ephemeral storage #18105

Closed
@tapichu

Description

@tapichu

Description

In April 2021, Fargate added support for requesting additional ephemeral storage.

Support for this feature has been added to the aws-ecs package, but is still not supported by the aws-ecs-patterns package.

Use Case

aws-ecs-patterns supports the following patterns:

  • ApplicationLoadBalancedFargateService
  • ApplicationMultipleTargetGroupsFargateService
  • NetworkLoadBalancedFargateService
  • NetworkMultipleTargateGroupsFargateService
  • QueueProcessingFargateService
  • ScheduledFargateTask

Users of these patterns are currently unable to request additional ephemeral storage beyond the 20 GiB provided by default. By adding support for this new feature, users will be able to request up to 200 GiB of ephemeral storage for their Fargate services.

Proposed Solution

The proposal is to follow the precedent set by the aws-ecs package:

const fargateTaskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDef', {
  memoryLimitMiB: 512,
  cpu: 256,
  ephemeralStorageGiB: 100
});

All the patterns in aws-ecs-patterns use under the hood aws-ecs's FargateTaskDefinition. Therefore, the proposed implementation will use the same naming convention, and forward the value to ecs.FargateTaskDefinition. All validation and setting of default values will be left to aws-ecs.

This is what a FargateScheduledTask would look like:

declare const cluster: ecs.Cluster;
const scheduledFargateTask = new ecsPatterns.ScheduledFargateTask(this, 'ScheduledFargateTask', {
  cluster,
  scheduledFargateTaskImageOptions: {
    image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
    memoryLimitMiB: 512,
    ephemeralStorageGiB: 100,
  },
  schedule: appscaling.Schedule.expression('rate(1 minute)'),
  platformVersion: ecs.FargatePlatformVersion.LATEST,
});

Other information

aws-ecs-patterns is inconsistent in how it exposes some configuration options. FargateScheduledTask puts the cpu/memory options inside FargateTaskImageOptions:

declare const cluster: ecs.Cluster;
const scheduledFargateTask = new ecsPatterns.ScheduledFargateTask(this, 'ScheduledFargateTask', {
  cluster,
  scheduledFargateTaskImageOptions: {
    image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
    cpu: 512,
    memoryLimitMiB: 1024,
  },
  schedule: appscaling.Schedule.expression('rate(1 minute)'),
  platformVersion: ecs.FargatePlatformVersion.LATEST,
});

By contrast, all the other patterns (ALB, NLB, Queue) set these values outside of the task image options, as top-level properties:

declare const cluster: ecs.Cluster;
const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
  cluster,
  memoryLimitMiB: 1024,
  cpu: 512,
  taskImageOptions: {
    image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
  },
});

For backwards-compatibility, this proposal will not attempt to address this inconsistency between the patterns, and will follow the existing convention set by each pattern.

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecs-patternsRelated to ecs-patterns libraryeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions