Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 2 tasks
tapichu opened this issue Dec 20, 2021 · 2 comments · Fixed by #29275
Closed
1 of 2 tasks

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

tapichu opened this issue Dec 20, 2021 · 2 comments · Fixed by #29275
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@tapichu
Copy link

tapichu commented Dec 20, 2021

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
@tapichu tapichu added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 20, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ecs-patterns Related to ecs-patterns library label Dec 20, 2021
tapichu added a commit to tapichu/aws-cdk that referenced this issue Dec 20, 2021
Fargate supports a new ephemeral storage option, to request up to 200
GiB of task storage. Support for it was added to aws-ecs but not to
aws-ecs-patterns.

This change adds support for ephemeral storage, so the following
patterns can take advantage of it:

* Application load balanced fargate service
* Application multiple target groups fargate service
* Network load balanced fargate service
* Network multiple target groups fargate service
* Queue processing fargate service
* Scheduled fargate task

Closes aws#18105

Signed-off-by: Eduardo Lopez <252504+tapichu@users.noreply.github.com>
tapichu added a commit to tapichu/aws-cdk that referenced this issue Dec 20, 2021
Fargate supports a new ephemeral storage option, to request up to 200
GiB of task storage. Support for it was added to aws-ecs but not to
aws-ecs-patterns.

This change adds support for ephemeral storage, so the following
patterns can take advantage of it:

* Application load balanced fargate service
* Application multiple target groups fargate service
* Network load balanced fargate service
* Network multiple target groups fargate service
* Queue processing fargate service
* Scheduled fargate task

Closes aws#18105

Signed-off-by: Eduardo Lopez <252504+tapichu@users.noreply.github.com>
@madeline-k madeline-k added p2 effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md and removed needs-triage This issue or PR still needs to be triaged. labels Dec 21, 2021
@madeline-k madeline-k removed their assignment Jan 25, 2022
@daveharmon
Copy link

Is there any update on this issue? This is blocking my team's adoption of this construct

@mergify mergify bot closed this as completed in #29275 Mar 1, 2024
mergify bot pushed a commit that referenced this issue Mar 1, 2024
…rvices (#29275)

### Issue # (if applicable)

Closes #18105.

### Reason for this change

In April 2021, Fargate added support for [requesting additional ephemeral storage](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/fargate-task-storage.html#fargate-task-storage-pv14).

Support for this feature has [been added](f1bf935#diff-dcfbc499b4d3c10afcd4e63ad0e4ecc54df2464e45af67f1fdae69d3fa2d43a0) to the aws-ecs package, but is still not supported by the aws-ecs-patterns package.

### Description of changes

This code change adds an optional field `ephemeralStorageGiB` in `packages/aws-cdk-lib/aws-ecs-patterns/lib/base/fargate-service-base.ts`, after other fields like `cpu` and `memoryLimitMiB`.

### Description of how you validated changes

Added unit tests and new integration tests.
Created a simple CDK application with the new constructs, and verified that it synthesized and deployed correctly.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

github-actions bot commented Mar 1, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment