Skip to content

Commit

Permalink
feat(efs): support for new elastic throughputmode (aws#23200)
Browse files Browse the repository at this point in the history
----

### 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*
  • Loading branch information
smsruthi authored and Brennan Ho committed Dec 9, 2022
1 parent 538f9ae commit ac1ff73
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-efs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
});
```

⚠️ An Amazon EFS file system's performance mode can't be MAX_IO when its throughputMode is ELASTIC.

⚠️ An Amazon EFS file system's performance mode can't be changed after the file system has been created.
Updating this property will replace the file system.

Expand Down
18 changes: 16 additions & 2 deletions packages/@aws-cdk/aws-efs/lib/efs-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import { CfnFileSystem, CfnMountTarget } from './efs.generated';
* @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-efs-filesystem.html#cfn-elasticfilesystem-filesystem-lifecyclepolicies
*/
export enum LifecyclePolicy {

/**
* After 1 day of not being accessed.
*/
AFTER_1_DAY = 'AFTER_1_DAY',

/**
* After 7 days of not being accessed.
*/
Expand Down Expand Up @@ -82,14 +88,19 @@ export enum PerformanceMode {
*/
export enum ThroughputMode {
/**
* This mode on Amazon EFS scales as the size of the file system in the standard storage class grows.
* This mode scales as the size of the file system in the standard storage class grows.
*/
BURSTING = 'bursting',

/**
* This mode can instantly provision the throughput of the file system (in MiB/s) independent of the amount of data stored.
*/
PROVISIONED = 'provisioned'
PROVISIONED = 'provisioned',

/**
* This mode scales the throughput automatically regardless of file system size.
*/
ELASTIC = 'elastic'
}

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

if (props.throughputMode === ThroughputMode.ELASTIC && props.performanceMode === PerformanceMode.MAX_IO) {
throw new Error('ThroughputMode ELASTIC is not supported for file systems with performanceMode MAX_IO');
}
// we explictly use 'undefined' to represent 'false' to maintain backwards compatibility since
// its considered an actual change in CloudFormations eyes, even though they have the same meaning.
const encrypted = props.encrypted ?? (FeatureFlags.of(this).isEnabled(
Expand Down
23 changes: 23 additions & 0 deletions packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ test('file system is created correctly with bursting throughput mode', () => {
});
});

test('file system is created correctly with elastic throughput mode', () => {
// WHEN
new FileSystem(stack, 'EfsFileSystem', {
vpc,
throughputMode: ThroughputMode.ELASTIC,
performanceMode: PerformanceMode.GENERAL_PURPOSE,
});
// THEN
Template.fromStack(stack).hasResourceProperties('AWS::EFS::FileSystem', {
ThroughputMode: 'elastic',
});
});

test('Exception when throughput mode is set to ELASTIC, performance mode cannot be MaxIO', () => {
expect(() => {
new FileSystem(stack, 'EfsFileSystem', {
vpc,
throughputMode: ThroughputMode.ELASTIC,
performanceMode: PerformanceMode.MAX_IO,
});
}).toThrowError(/ThroughputMode ELASTIC is not supported for file systems with performanceMode MAX_IO/);
});

test('Exception when throughput mode is set to PROVISIONED, but provisioned throughput is not set', () => {
expect(() => {
new FileSystem(stack, 'EfsFileSystem', {
Expand Down

0 comments on commit ac1ff73

Please sign in to comment.