UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 14.1 kB
"use strict";var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a,LustreFileSystem_1;Object.defineProperty(exports,"__esModule",{value:!0}),exports.LustreFileSystem=exports.LustreDataCompressionType=exports.DriveCacheType=exports.LustreAutoImportPolicy=exports.LustreDeploymentType=exports.FileSystemTypeVersion=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var file_system_1=()=>{var tmp=require("./file-system");return file_system_1=()=>tmp,tmp},fsx_generated_1=()=>{var tmp=require("./fsx.generated");return fsx_generated_1=()=>tmp,tmp},aws_ec2_1=()=>{var tmp=require("../../aws-ec2");return aws_ec2_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp},FileSystemTypeVersion;(function(FileSystemTypeVersion2){FileSystemTypeVersion2.V_2_10="2.10",FileSystemTypeVersion2.V_2_12="2.12",FileSystemTypeVersion2.V_2_15="2.15"})(FileSystemTypeVersion||(exports.FileSystemTypeVersion=FileSystemTypeVersion={}));var LustreDeploymentType;(function(LustreDeploymentType2){LustreDeploymentType2.SCRATCH_1="SCRATCH_1",LustreDeploymentType2.SCRATCH_2="SCRATCH_2",LustreDeploymentType2.PERSISTENT_1="PERSISTENT_1",LustreDeploymentType2.PERSISTENT_2="PERSISTENT_2"})(LustreDeploymentType||(exports.LustreDeploymentType=LustreDeploymentType={}));var LustreAutoImportPolicy;(function(LustreAutoImportPolicy2){LustreAutoImportPolicy2.NONE="NONE",LustreAutoImportPolicy2.NEW="NEW",LustreAutoImportPolicy2.NEW_CHANGED="NEW_CHANGED",LustreAutoImportPolicy2.NEW_CHANGED_DELETED="NEW_CHANGED_DELETED"})(LustreAutoImportPolicy||(exports.LustreAutoImportPolicy=LustreAutoImportPolicy={}));var DriveCacheType;(function(DriveCacheType2){DriveCacheType2.NONE="NONE",DriveCacheType2.READ="READ"})(DriveCacheType||(exports.DriveCacheType=DriveCacheType={}));var LustreDataCompressionType;(function(LustreDataCompressionType2){LustreDataCompressionType2.NONE="NONE",LustreDataCompressionType2.LZ4="LZ4"})(LustreDataCompressionType||(exports.LustreDataCompressionType=LustreDataCompressionType={}));let LustreFileSystem=LustreFileSystem_1=class LustreFileSystem2 extends file_system_1().FileSystemBase{static fromLustreFileSystemAttributes(scope,id,attrs){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_fsx_FileSystemAttributes(attrs)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromLustreFileSystemAttributes),error}class Import extends file_system_1().FileSystemBase{constructor(){super(...arguments),this.dnsName=attrs.dnsName,this.fileSystemId=attrs.fileSystemId,this.connections=LustreFileSystem_1.configureConnections(attrs.securityGroup)}}return new Import(scope,id)}static configureConnections(securityGroup){return new(aws_ec2_1()).Connections({securityGroups:[securityGroup],defaultPort:aws_ec2_1().Port.tcpRange(LustreFileSystem_1.DEFAULT_PORT_RANGE.startPort,LustreFileSystem_1.DEFAULT_PORT_RANGE.endPort)})}constructor(scope,id,props){super(scope,id);try{jsiiDeprecationWarnings().aws_cdk_lib_aws_fsx_LustreFileSystemProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,LustreFileSystem2),error}(0,metadata_resource_1().addConstructMetadata)(this,props),this.validateProps(props);const updatedLustureProps={importedFileChunkSize:props.lustreConfiguration.importedFileChunkSizeMiB,weeklyMaintenanceStartTime:props.lustreConfiguration.weeklyMaintenanceStartTime?.toTimestamp(),automaticBackupRetentionDays:props.lustreConfiguration.automaticBackupRetention?.toDays(),dailyAutomaticBackupStartTime:props.lustreConfiguration.dailyAutomaticBackupStartTime?.toTimestamp(),driveCacheType:props.lustreConfiguration.driveCacheType??(props.storageType===file_system_1().StorageType.HDD?DriveCacheType.NONE:void 0)},lustreConfiguration=Object.assign({},props.lustreConfiguration,updatedLustureProps),securityGroup=props.securityGroup||new(aws_ec2_1()).SecurityGroup(this,"FsxLustreSecurityGroup",{vpc:props.vpc});securityGroup.addIngressRule(securityGroup,aws_ec2_1().Port.tcpRange(LustreFileSystem_1.DEFAULT_PORT_RANGE.startPort,LustreFileSystem_1.DEFAULT_PORT_RANGE.endPort)),this.connections=LustreFileSystem_1.configureConnections(securityGroup),this.fileSystem=new(fsx_generated_1()).CfnFileSystem(this,"Resource",{fileSystemType:LustreFileSystem_1.DEFAULT_FILE_SYSTEM_TYPE,subnetIds:[props.vpcSubnet.subnetId],backupId:props.backupId,kmsKeyId:props.kmsKey?props.kmsKey.keyId:void 0,lustreConfiguration,securityGroupIds:[securityGroup.securityGroupId],storageCapacity:props.storageCapacityGiB,fileSystemTypeVersion:props.fileSystemTypeVersion,storageType:props.storageType}),this.fileSystem.applyRemovalPolicy(props.removalPolicy),this.fileSystemId=this.fileSystem.ref,this.dnsName=`${this.fileSystemId}.fsx.${this.env.region}.${core_1().Aws.URL_SUFFIX}`,this.mountName=this.fileSystem.attrLustreMountName}validateProps(props){const lustreConfiguration=props.lustreConfiguration,deploymentType=lustreConfiguration.deploymentType,perUnitStorageThroughput=lustreConfiguration.perUnitStorageThroughput;this.validateImportPath(lustreConfiguration.importPath),this.validateExportPath(lustreConfiguration.exportPath,lustreConfiguration.importPath),this.validateImportedFileChunkSize(lustreConfiguration.importedFileChunkSizeMiB),this.validateAutoImportPolicy(deploymentType,lustreConfiguration.importPath,lustreConfiguration.autoImportPolicy),this.validateAutomaticBackupRetention(deploymentType,lustreConfiguration.automaticBackupRetention),this.validateDailyAutomaticBackupStartTime(lustreConfiguration.automaticBackupRetention,lustreConfiguration.dailyAutomaticBackupStartTime),this.validatePerUnitStorageThroughput(deploymentType,perUnitStorageThroughput,props.storageType),this.validateStorageCapacity(deploymentType,props.storageCapacityGiB,props.storageType,perUnitStorageThroughput),this.validateStorageType(deploymentType,props.storageType),this.validateDriveCacheType(deploymentType,props.storageType,lustreConfiguration.driveCacheType),this.validateFiileSystemTypeVersion(deploymentType,props.fileSystemTypeVersion)}validateDriveCacheType(deploymentType,storageType,driveCacheType){if(driveCacheType&&(deploymentType!==LustreDeploymentType.PERSISTENT_1||storageType!==file_system_1().StorageType.HDD))throw new(core_1()).ValidationError(`driveCacheType can only be set for PERSISTENT_1 HDD storage type, got: ${deploymentType} and ${storageType}`,this)}validateStorageType(deploymentType,storageType){if(storageType&&storageType===file_system_1().StorageType.HDD&&deploymentType!==LustreDeploymentType.PERSISTENT_1)throw new(core_1()).ValidationError(`Storage type HDD is only supported for PERSISTENT_1 deployment type, got: ${deploymentType}`,this)}validateFiileSystemTypeVersion(deploymentType,fileSystemTypeVersion){if(fileSystemTypeVersion!==void 0&&fileSystemTypeVersion===FileSystemTypeVersion.V_2_10&&!deploymentType.startsWith("SCRATCH")&&deploymentType!==LustreDeploymentType.PERSISTENT_1)throw new(core_1()).ValidationError("fileSystemTypeVersion V_2_10 is only supported for SCRATCH and PERSISTENT_1 deployment types",this)}validateAutoImportPolicy(deploymentType,importPath,autoImportPolicy){if(autoImportPolicy!==void 0){if(importPath===void 0)throw new(core_1()).ValidationError("autoImportPolicy requires importPath to be defined",this);if(deploymentType===LustreDeploymentType.PERSISTENT_2)throw new(core_1()).ValidationError("autoImportPolicy is not supported with PERSISTENT_2 deployments",this)}}validateExportPath(exportPath,importPath){if(exportPath!==void 0){if(importPath===void 0)throw new(core_1()).ValidationError("Cannot define an export path without also defining an import path",this);if(!(core_1().Token.isUnresolved(exportPath)&&core_1().Token.isUnresolved(importPath))){if(core_1().Token.isUnresolved(importPath)!==core_1().Token.isUnresolved(exportPath))throw new(core_1()).ValidationError("The importPath and exportPath must each be Tokens or not Tokens, you cannot use a mix",this);if(!exportPath.startsWith(importPath))throw new(core_1()).ValidationError(`The export path "${exportPath}" is invalid. Expecting the format: s3://{IMPORT_PATH}/optional-prefix`,this);if(exportPath.length>900)throw new(core_1()).ValidationError(`The export path "${exportPath}" exceeds the maximum length of 900 characters`,this)}}}validateImportedFileChunkSize(importedFileChunkSize){if(importedFileChunkSize!==void 0&&(importedFileChunkSize<1||importedFileChunkSize>512e3))throw new(core_1()).ValidationError(`importedFileChunkSize cannot be ${importedFileChunkSize} MiB. It must be a value from 1 to 512,000 MiB`,this)}validateImportPath(importPath){if(importPath===void 0||core_1().Token.isUnresolved(importPath))return;const regexp=/^s3:\/\//;if(importPath.search(regexp)===-1)throw new(core_1()).ValidationError(`The import path "${importPath}" is invalid. Expecting the format: s3://{BUCKET_NAME}/optional-prefix`,this);if(importPath.length>900)throw new(core_1()).ValidationError(`The import path "${importPath}" exceeds the maximum length of 900 characters`,this)}validatePerUnitStorageThroughput(deploymentType,perUnitStorageThroughput,storageType){if(perUnitStorageThroughput!==void 0){if(deploymentType!==LustreDeploymentType.PERSISTENT_1&&deploymentType!==LustreDeploymentType.PERSISTENT_2)throw new(core_1()).ValidationError("perUnitStorageThroughput can only be set for the PERSISTENT_1/PERSISTENT_2 deployment types, received: "+deploymentType,this);if(deploymentType===LustreDeploymentType.PERSISTENT_1){if(storageType===file_system_1().StorageType.HDD&&![12,40].includes(perUnitStorageThroughput))throw new(core_1()).ValidationError(`perUnitStorageThroughput must be 12 or 40 MB/s/TiB for PERSISTENT_1 HDD storage, got: ${perUnitStorageThroughput}`,this);if((storageType===void 0||storageType===file_system_1().StorageType.SSD)&&![50,100,200].includes(perUnitStorageThroughput))throw new(core_1()).ValidationError("perUnitStorageThroughput must be 50, 100, or 200 MB/s/TiB for PERSISTENT_1 SSD storage, got: "+perUnitStorageThroughput,this)}if(deploymentType===LustreDeploymentType.PERSISTENT_2&&![125,250,500,1e3].includes(perUnitStorageThroughput))throw new(core_1()).ValidationError(`perUnitStorageThroughput must be 125, 250, 500 or 1000 MB/s/TiB for PERSISTENT_2 deployment type, got: ${perUnitStorageThroughput}`,this)}}validateStorageCapacity(deploymentType,storageCapacity,storageType,perUnitStorageThroughput){if(deploymentType===LustreDeploymentType.SCRATCH_1&&![1200,2400,3600].includes(storageCapacity)&&storageCapacity%3600!==0)throw new(core_1()).ValidationError(`storageCapacity must be 1,200, 2,400, 3,600, or a multiple of 3,600 for SCRATCH_1 deployment type, got ${storageCapacity}.`,this);if((deploymentType===LustreDeploymentType.PERSISTENT_2||deploymentType===LustreDeploymentType.SCRATCH_2)&&![1200,2400].includes(storageCapacity)&&storageCapacity%2400!==0)throw new(core_1()).ValidationError(`storageCapacity must be 1,200, 2,400, or a multiple of 2,400 for SCRATCH_2 and PERSISTENT_2 deployment types, got ${storageCapacity}`,this);if(deploymentType===LustreDeploymentType.PERSISTENT_1){if(storageType===file_system_1().StorageType.HDD){if(perUnitStorageThroughput===12&&storageCapacity%6e3!==0)throw new(core_1()).ValidationError(`storageCapacity must be a multiple of 6,000 for PERSISTENT_1 HDD storage with 12 MB/s/TiB throughput, got ${storageCapacity}`,this);if(perUnitStorageThroughput===40&&storageCapacity%1800!==0)throw new(core_1()).ValidationError(`storageCapacity must be a multiple of 1,800 for PERSISTENT_1 HDD storage with 40 MB/s/TiB throughput, got ${storageCapacity}`,this)}else if(![1200,2400].includes(storageCapacity)&&storageCapacity%2400!==0)throw new(core_1()).ValidationError(`storageCapacity must be 1,200, 2,400, or a multiple of 2,400 for PERSISTENT_1 SSD storage, got ${storageCapacity}`,this)}}validateAutomaticBackupRetention(deploymentType,automaticBackupRetention){if(automaticBackupRetention){const automaticBackupRetentionDays=automaticBackupRetention.toDays();if([LustreDeploymentType.SCRATCH_1,LustreDeploymentType.SCRATCH_2].includes(deploymentType)&&automaticBackupRetentionDays>0)throw new(core_1()).ValidationError("automatic backups is not supported on scratch file systems",this);if(automaticBackupRetentionDays>90)throw new(core_1()).ValidationError(`automaticBackupRetention period must be between 0 and 90 days. received: ${automaticBackupRetentionDays}`,this)}}validateDailyAutomaticBackupStartTime(automaticBackupRetention,dailyAutomaticBackupStartTime){if(!dailyAutomaticBackupStartTime)return;const automaticBackupDisabled=!automaticBackupRetention||automaticBackupRetention?.toDays()===core_1().Duration.days(0).toDays();if(dailyAutomaticBackupStartTime&&automaticBackupDisabled)throw new(core_1()).ValidationError("automaticBackupRetention period must be set a non-zero day when dailyAutomaticBackupStartTime is set",this)}};exports.LustreFileSystem=LustreFileSystem,_a=JSII_RTTI_SYMBOL_1,LustreFileSystem[_a]={fqn:"aws-cdk-lib.aws_fsx.LustreFileSystem",version:"2.202.0"},LustreFileSystem.PROPERTY_INJECTION_ID="aws-cdk-lib.aws-fsx.LustreFileSystem",LustreFileSystem.DEFAULT_FILE_SYSTEM_TYPE="LUSTRE",LustreFileSystem.DEFAULT_PORT_RANGE={startPort:988,endPort:1023},exports.LustreFileSystem=LustreFileSystem=LustreFileSystem_1=__decorate([prop_injectable_1().propertyInjectable],LustreFileSystem);