diff --git a/packages/@aws-cdk/aws-fsx/lib/lustre-file-system.ts b/packages/@aws-cdk/aws-fsx/lib/lustre-file-system.ts index b88b3e99ac081..7b145252941cb 100644 --- a/packages/@aws-cdk/aws-fsx/lib/lustre-file-system.ts +++ b/packages/@aws-cdk/aws-fsx/lib/lustre-file-system.ts @@ -21,7 +21,12 @@ export enum LustreDeploymentType { /** * Long term storage. Data is replicated and file servers are replaced if they fail. */ - PERSISTENT_1 = 'PERSISTENT_1' + PERSISTENT_1 = 'PERSISTENT_1', + /** + * Newer type of long term storage with higher throughput tiers. + * Data is replicated and file servers are replaced if they fail. + */ + PERSISTENT_2 = 'PERSISTENT_2', } /** @@ -276,12 +281,20 @@ export class LustreFileSystem extends FileSystemBase { private validatePerUnitStorageThroughput(deploymentType: LustreDeploymentType, perUnitStorageThroughput?: number) { if (perUnitStorageThroughput === undefined) { return; } - if (deploymentType !== LustreDeploymentType.PERSISTENT_1) { - throw new Error('perUnitStorageThroughput can only be set for the PERSISTENT_1 deployment type'); + if (deploymentType !== LustreDeploymentType.PERSISTENT_1 && deploymentType !== LustreDeploymentType.PERSISTENT_2) { + throw new Error('perUnitStorageThroughput can only be set for the PERSISTENT_1/PERSISTENT_2 deployment types, received: ' + deploymentType); + } + + if (deploymentType === LustreDeploymentType.PERSISTENT_1) { + if (![50, 100, 200].includes(perUnitStorageThroughput)) { + throw new Error('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB for PERSISTENT_1 deployment type, got: ' + perUnitStorageThroughput); + } } - if (![50, 100, 200].includes(perUnitStorageThroughput)) { - throw new Error('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB'); + if (deploymentType === LustreDeploymentType.PERSISTENT_2) { + if (![125, 250, 500, 1000].includes(perUnitStorageThroughput)) { + throw new Error('perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB for PERSISTENT_2 deployment type, got: ' + perUnitStorageThroughput); + } } } diff --git a/packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts b/packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts index 6f581475dbe3d..cff4f97f1149f 100644 --- a/packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts +++ b/packages/@aws-cdk/aws-fsx/test/lustre-file-system.test.ts @@ -436,10 +436,16 @@ describe('FSx for Lustre File System', () => { }); }); - test('invalid perUnitStorageThroughput', () => { + test.each([ + 1, + 125, + 250, + 500, + 1000, + ])('invalid perUnitStorageThroughput', (invalidValue: number) => { lustreConfiguration = { deploymentType: LustreDeploymentType.PERSISTENT_1, - perUnitStorageThroughput: 1, + perUnitStorageThroughput: invalidValue, }; expect(() => { @@ -449,7 +455,7 @@ describe('FSx for Lustre File System', () => { vpc, vpcSubnet, }); - }).toThrowError('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB'); + }).toThrowError('perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB for PERSISTENT_1 deployment type, got: ' + invalidValue); }); test('setting perUnitStorageThroughput on wrong deploymentType', () => { @@ -465,7 +471,57 @@ describe('FSx for Lustre File System', () => { vpc, vpcSubnet, }); - }).toThrowError('perUnitStorageThroughput can only be set for the PERSISTENT_1 deployment type'); + }).toThrowError('perUnitStorageThroughput can only be set for the PERSISTENT_1/PERSISTENT_2 deployment types'); + }); + }); + + describe('perUnitStorageThroughput_Persistent_2', () => { + test.each([ + 125, + 250, + 500, + 1000, + ])('valid perUnitStorageThroughput of %d', (throughput: number) => { + lustreConfiguration = { + deploymentType: LustreDeploymentType.PERSISTENT_2, + perUnitStorageThroughput: throughput, + }; + + new LustreFileSystem(stack, 'FsxFileSystem', { + lustreConfiguration, + storageCapacityGiB: storageCapacity, + vpc, + vpcSubnet, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::FSx::FileSystem', { + LustreConfiguration: { + DeploymentType: LustreDeploymentType.PERSISTENT_2, + PerUnitStorageThroughput: throughput, + }, + }); + }); + + test.each([ + 1, + 50, + 100, + 200, + 550, + ])('invalid perUnitStorageThroughput', (invalidValue: number) => { + lustreConfiguration = { + deploymentType: LustreDeploymentType.PERSISTENT_2, + perUnitStorageThroughput: invalidValue, + }; + + expect(() => { + new LustreFileSystem(stack, 'FsxFileSystem', { + lustreConfiguration, + storageCapacityGiB: storageCapacity, + vpc, + vpcSubnet, + }); + }).toThrowError('perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB for PERSISTENT_2 deployment type, got: ' + invalidValue); }); }); @@ -477,6 +533,9 @@ describe('FSx for Lustre File System', () => { [1200, LustreDeploymentType.PERSISTENT_1], [2400, LustreDeploymentType.PERSISTENT_1], [4800, LustreDeploymentType.PERSISTENT_1], + [1200, LustreDeploymentType.PERSISTENT_2], + [2400, LustreDeploymentType.PERSISTENT_2], + [4800, LustreDeploymentType.PERSISTENT_2], ])('proper multiple for storage capacity of %d on %s', (value: number, deploymentType: LustreDeploymentType) => { lustreConfiguration = { deploymentType, @@ -502,6 +561,8 @@ describe('FSx for Lustre File System', () => { [2401, LustreDeploymentType.SCRATCH_2], [1, LustreDeploymentType.PERSISTENT_1], [2401, LustreDeploymentType.PERSISTENT_1], + [1, LustreDeploymentType.PERSISTENT_2], + [2401, LustreDeploymentType.PERSISTENT_2], ])('invalid value of %d for storage capacity on %s', (invalidValue: number, deploymentType: LustreDeploymentType) => { lustreConfiguration = { deploymentType,