Skip to content

Commit d7ae159

Browse files
authored
feat(efs): support for new elastic throughputmode (#23200)
---- ### All Submissions: * [ yes] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7882e0e commit d7ae159

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

packages/@aws-cdk/aws-efs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
4040
});
4141
```
4242

43+
⚠️ An Amazon EFS file system's performance mode can't be MAX_IO when its throughputMode is ELASTIC.
44+
4345
⚠️ An Amazon EFS file system's performance mode can't be changed after the file system has been created.
4446
Updating this property will replace the file system.
4547

packages/@aws-cdk/aws-efs/lib/efs-file-system.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import { CfnFileSystem, CfnMountTarget } from './efs.generated';
1313
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html#cfn-elasticfilesystem-filesystem-lifecyclepolicies
1414
*/
1515
export enum LifecyclePolicy {
16+
17+
/**
18+
* After 1 day of not being accessed.
19+
*/
20+
AFTER_1_DAY = 'AFTER_1_DAY',
21+
1622
/**
1723
* After 7 days of not being accessed.
1824
*/
@@ -82,14 +88,19 @@ export enum PerformanceMode {
8288
*/
8389
export enum ThroughputMode {
8490
/**
85-
* This mode on Amazon EFS scales as the size of the file system in the standard storage class grows.
91+
* This mode scales as the size of the file system in the standard storage class grows.
8692
*/
8793
BURSTING = 'bursting',
8894

8995
/**
9096
* This mode can instantly provision the throughput of the file system (in MiB/s) independent of the amount of data stored.
9197
*/
92-
PROVISIONED = 'provisioned'
98+
PROVISIONED = 'provisioned',
99+
100+
/**
101+
* This mode scales the throughput automatically regardless of file system size.
102+
*/
103+
ELASTIC = 'elastic'
93104
}
94105

95106
/**
@@ -333,6 +344,9 @@ export class FileSystem extends FileSystemBase {
333344
throw new Error('Property provisionedThroughputPerSecond is required when throughputMode is PROVISIONED');
334345
}
335346

347+
if (props.throughputMode === ThroughputMode.ELASTIC && props.performanceMode === PerformanceMode.MAX_IO) {
348+
throw new Error('ThroughputMode ELASTIC is not supported for file systems with performanceMode MAX_IO');
349+
}
336350
// we explictly use 'undefined' to represent 'false' to maintain backwards compatibility since
337351
// its considered an actual change in CloudFormations eyes, even though they have the same meaning.
338352
const encrypted = props.encrypted ?? (FeatureFlags.of(this).isEnabled(

packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ test('file system is created correctly with bursting throughput mode', () => {
162162
});
163163
});
164164

165+
test('file system is created correctly with elastic throughput mode', () => {
166+
// WHEN
167+
new FileSystem(stack, 'EfsFileSystem', {
168+
vpc,
169+
throughputMode: ThroughputMode.ELASTIC,
170+
performanceMode: PerformanceMode.GENERAL_PURPOSE,
171+
});
172+
// THEN
173+
Template.fromStack(stack).hasResourceProperties('AWS::EFS::FileSystem', {
174+
ThroughputMode: 'elastic',
175+
});
176+
});
177+
178+
test('Exception when throughput mode is set to ELASTIC, performance mode cannot be MaxIO', () => {
179+
expect(() => {
180+
new FileSystem(stack, 'EfsFileSystem', {
181+
vpc,
182+
throughputMode: ThroughputMode.ELASTIC,
183+
performanceMode: PerformanceMode.MAX_IO,
184+
});
185+
}).toThrowError(/ThroughputMode ELASTIC is not supported for file systems with performanceMode MAX_IO/);
186+
});
187+
165188
test('Exception when throughput mode is set to PROVISIONED, but provisioned throughput is not set', () => {
166189
expect(() => {
167190
new FileSystem(stack, 'EfsFileSystem', {

0 commit comments

Comments
 (0)