UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.63 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.launchTemplateBlockDeviceMappings=exports.instanceBlockDeviceMappings=void 0;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){return synthesizeBlockDeviceMappings(construct,blockDevices,{})}exports.instanceBlockDeviceMappings=instanceBlockDeviceMappings;function launchTemplateBlockDeviceMappings(construct,blockDevices){return synthesizeBlockDeviceMappings(construct,blockDevices,"")}exports.launchTemplateBlockDeviceMappings=launchTemplateBlockDeviceMappings;function synthesizeBlockDeviceMappings(construct,blockDevices,noDeviceValue){return blockDevices.map(({deviceName,volume,mappingEnabled})=>{const{virtualName,ebsDevice:ebs}=volume;let finalEbs;if(ebs){const{iops,volumeType,kmsKey,...rest}=ebs;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 Error("iops property is required with volumeType: EbsDeviceVolumeType.IO1 and EbsDeviceVolumeType.IO2");finalEbs={...rest,iops,volumeType,kmsKeyId:kmsKey?.keyArn}}else finalEbs=void 0;return{deviceName,ebs:finalEbs,virtualName,noDevice:mappingEnabled===!1?noDeviceValue:void 0}})}