diff --git a/packages/@aws-cdk/aws-efs/README.md b/packages/@aws-cdk/aws-efs/README.md index 058198d0c897e..a0ea3b8432341 100644 --- a/packages/@aws-cdk/aws-efs/README.md +++ b/packages/@aws-cdk/aws-efs/README.md @@ -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. diff --git a/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts b/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts index b6f512ed071e6..57b7e295068f0 100644 --- a/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts +++ b/packages/@aws-cdk/aws-efs/lib/efs-file-system.ts @@ -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. */ @@ -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' } /** @@ -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( diff --git a/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts b/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts index 39e172a479867..96715f688c968 100644 --- a/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts +++ b/packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts @@ -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', {