aws / aws/aws-cdk

ECS: Mount EFS volume

Open
#13,442 11 comments 5 reactions 0 assignees View on GitHub
@aws-cdk/aws-ecs @aws-cdk/aws-efs feature-request feature/service-integration needs-cfn p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

I want to be able to create an EFS volume and mount it in a docker container with CDK.

I tried figuring out how to use an Access Point but can't figure out how to specify the AP ID in a `Volume` definition. Don't see anything about access points in ECS docs.
I tried creating an EFS volume and mounting it but I can't write to it and I have no way to change the permissions. I'm using a community docker image I'd rather use as-is without modifying.

Surely this is a common use case - create a writeable persistent volume and mount it.

### Use Case

I'm building this - https://github.com/jetbridge/lemmy-cdk

### Proposed Solution

A way to mount an EFS access point in a fargate task definition or a way to mount the entire EFS volume as writeable.

### Other

```typescript
const fs = new FileSystem(this, "FS", {
vpc,
encrypted: true,
lifecyclePolicy: LifecyclePolicy.AFTER_60_DAYS,
performanceMode: PerformanceMode.GENERAL_PURPOSE,
removalPolicy: RemovalPolicy.RETAIN,
fileSystemName: "LemmyFS",
enableAutomaticBackups: false,
});

const assetVolume: Volume = {
efsVolumeConfiguration: {
fileSystemId: fs.fileSystemId,
},
name: "assets",
};

const container = taskDef.addContainer(PICTRS_NAME, {
image: ContainerImage.fromRegistry(PICTRS_IMAGE),
logging: LogDriver.awsLogs({ streamPrefix: PICTRS_NAME }),
environment: { PICTRS_PATH: "/mnt/assets" },
});
// mount asset storage volume
container.addMountPoints({
sourceVolume: assetVolume.name,
containerPath: "/mnt/assets",
readOnly: false,
});
```

Screen Shot 2021-03-06 at 2 12 50 PM

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Contributor guide

Open the contributing guide

Research direction

Review the ECS task definition's Volume and efsVolumeConfiguration, along with the Fargate task definition and addMountPoints usage shown in the example. Compare the requested EFS access-point or writable-volume behavior with the current CDK model, and define completion as a task definition that mounts persistent EFS storage for the unchanged container image.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.