Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Cluster: use EFS access point
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Oct 18, 2024
1 parent 03b7bc2 commit 7690166
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
16 changes: 14 additions & 2 deletions platform/src/components/aws/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ export interface ClusterServiceArgs {
* }
* ```
*/
command?: Input<string[]>;
command?: Input<Input<string>[]>;
/**
* The entrypoint to override the default entrypoint in the container.
* @example
Expand Down Expand Up @@ -896,7 +896,19 @@ export interface ClusterServiceArgs {
/**
* The Amazon EFS file system to mount.
*/
efs: Input<Efs | string>;
efs: Input<
| Efs
| {
/**
* The ID of the EFS file system.
*/
fileSystem: Input<string>;
/**
* The ID of the EFS access point.
*/
accessPoint: Input<string>;
}
>;
/**
* The path to mount the volumne.
*/
Expand Down
7 changes: 7 additions & 0 deletions platform/src/components/aws/efs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ export class Efs extends Component {
return this._fileSystem.id;
}

/**
* The ID of the EFS access point.
*/
public get accessPoint() {
return this._accessPoint.id;
}

/**
* The underlying [resources](/docs/components/#nodes) this component creates.
*/
Expand Down
23 changes: 16 additions & 7 deletions platform/src/components/aws/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ export class Service extends Component implements Link.Linkable {
(volumes) =>
volumes?.map((volume) => ({
path: volume.path,
efs: volume.efs instanceof Efs ? volume.efs.id : volume.efs,
efs:
volume.efs instanceof Efs
? {
fileSystem: volume.efs.id,
accessPoint: volume.efs.accessPoint,
}
: volume.efs,
})),
);
}
Expand Down Expand Up @@ -623,16 +629,19 @@ export class Service extends Component implements Link.Linkable {
executionRoleArn: executionRole.arn,
taskRoleArn: taskRole.arn,
volumes: output(containers).apply((containers) => {
const uniqueFileSystemIds: Set<string> = new Set();
const uniqueAccessPoints: Set<string> = new Set();
return containers.flatMap((container) =>
(container.volumes ?? []).flatMap((volume) => {
if (uniqueFileSystemIds.has(volume.efs)) return [];
uniqueFileSystemIds.add(volume.efs);
if (uniqueAccessPoints.has(volume.efs.accessPoint)) return [];
uniqueAccessPoints.add(volume.efs.accessPoint);
return {
name: volume.efs,
name: volume.efs.accessPoint,
efsVolumeConfiguration: {
fileSystemId: volume.efs,
fileSystemId: volume.efs.fileSystem,
transitEncryption: "ENABLED",
authorizationConfig: {
accessPointId: volume.efs.accessPoint,
},
},
};
}),
Expand Down Expand Up @@ -667,7 +676,7 @@ export class Service extends Component implements Link.Linkable {
initProcessEnabled: true,
},
mountPoints: container.volumes?.map((volume) => ({
sourceVolume: volume.efs,
sourceVolume: volume.efs.accessPoint,
containerPath: volume.path,
})),
};
Expand Down

0 comments on commit 7690166

Please sign in to comment.