aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 2.7 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0}),exports.instanceBlockDeviceMappings=instanceBlockDeviceMappings,exports.launchTemplateBlockDeviceMappings=launchTemplateBlockDeviceMappings;var core_1=()=>{var tmp=require("../../../core");return core_1=()=>tmp,tmp},volume_1=()=>{var tmp=require("../volume");return volume_1=()=>tmp,tmp};function instanceBlockDeviceMappings(construct,blockDevices){for(const blockDevice of blockDevices)blockDevice.volume.ebsDevice?.throughput!==void 0&&core_1().Annotations.of(construct).addWarningV2("@aws-cdk/aws-ec2:throughputNotSupported","The throughput property is not supported on EC2 instances. Use a Launch Template instead. See https://github.com/aws/aws-cdk/issues/34033 for more information.");return synthesizeBlockDeviceMappings(construct,blockDevices,{})}function launchTemplateBlockDeviceMappings(construct,blockDevices){return synthesizeBlockDeviceMappings(construct,blockDevices,"")}function synthesizeBlockDeviceMappings(construct,blockDevices,noDeviceValue){return blockDevices.map(({deviceName,volume,mappingEnabled})=>{const{virtualName,ebsDevice:ebs}=volume;let finalEbs;if(ebs){const{iops,throughput,volumeType,kmsKey,...rest}=ebs;if(throughput){if(volumeType!==volume_1().EbsDeviceVolumeType.GP3)throw new(core_1()).ValidationError(`'throughput' requires 'volumeType': ${volume_1().EbsDeviceVolumeType.GP3}, got: ${volumeType}.`,construct);if(!Number.isInteger(throughput))throw new(core_1()).ValidationError(`'throughput' must be an integer, got: ${throughput}.`,construct);if(throughput<125||throughput>1e3)throw new(core_1()).ValidationError(`'throughput' must be between 125 and 1000, got ${throughput}.`,construct);const maximumThroughputRatio=.25;if(iops){const iopsRatio=throughput/iops;if(iopsRatio>maximumThroughputRatio)throw new(core_1()).ValidationError(`Throughput (MiBps) to iops ratio of ${iopsRatio} is too high; maximum is ${maximumThroughputRatio} MiBps per iops`,construct)}}if(iops)volumeType!==volume_1().EbsDeviceVolumeType.IO1&&volumeType!==volume_1().EbsDeviceVolumeType.IO2&&volumeType!==volume_1().EbsDeviceVolumeType.GP3&&core_1().Annotations.of(construct).addWarningV2("@aws-cdk/aws-ec2:iopsIgnored","iops will be ignored without volumeType: IO1, IO2, or GP3");else if(volumeType===volume_1().EbsDeviceVolumeType.IO1||volumeType===volume_1().EbsDeviceVolumeType.IO2)throw new(core_1()).ValidationError("iops property is required with volumeType: EbsDeviceVolumeType.IO1 and EbsDeviceVolumeType.IO2",construct);finalEbs={...rest,iops,throughput,volumeType,kmsKeyId:kmsKey?.keyArn}}else finalEbs=void 0;return{deviceName,ebs:finalEbs,virtualName,noDevice:mappingEnabled===!1?noDeviceValue:void 0}})}
;