Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ec2): max iops value for io2 EBS volume is wrong #28695

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/aws-cdk-lib/aws-ec2/lib/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export interface VolumeProps {

/**
* The size of the volume, in GiBs. You must specify either a snapshot ID or a volume size.
* See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html
* See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html
* for details on the allowable size for each type of volume.
*
* @default If you're creating the volume from a snapshot and don't specify a volume size, the default is the snapshot size.
Expand Down Expand Up @@ -427,7 +427,7 @@ export interface VolumeProps {
/**
* The number of I/O operations per second (IOPS) to provision for the volume. The maximum ratio is 50 IOPS/GiB for PROVISIONED_IOPS_SSD,
* and 500 IOPS/GiB for both PROVISIONED_IOPS_SSD_IO2 and GENERAL_PURPOSE_SSD_GP3.
* See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html
* See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html
* for more information.
*
* This parameter is valid only for PROVISIONED_IOPS_SSD, PROVISIONED_IOPS_SSD_IO2 and GENERAL_PURPOSE_SSD_GP3 volumes.
Expand All @@ -446,7 +446,7 @@ export interface VolumeProps {
/**
* The throughput that the volume supports, in MiB/s
* Takes a minimum of 125 and maximum of 1000.
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html#cfn-ec2-ebs-volume-throughput
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html#cfn-ec2-volume-throughput
* @default - 125 MiB/s. Only valid on gp3 volumes.
*/
readonly throughput?: number;
Expand Down Expand Up @@ -691,11 +691,11 @@ export class Volume extends VolumeBase {
);
}
// Enforce minimum & maximum IOPS:
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html
const iopsRanges: { [key: string]: { Min: number, Max: number } } = {};
iopsRanges[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3] = { Min: 3000, Max: 16000 };
iopsRanges[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD] = { Min: 100, Max: 64000 };
iopsRanges[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2] = { Min: 100, Max: 64000 };
iopsRanges[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2] = { Min: 100, Max: 256000 };
const { Min, Max } = iopsRanges[volumeType];
if (props.iops < Min || props.iops > Max) {
throw new Error(`\`${volumeType}\` volumes iops must be between ${Min} and ${Max}.`);
Expand Down Expand Up @@ -739,7 +739,7 @@ export class Volume extends VolumeBase {
if (props.size) {
const size = props.size.toGibibytes({ rounding: SizeRoundingBehavior.FAIL });
// Enforce minimum & maximum volume size:
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html
// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html
const sizeRanges: { [key: string]: { Min: number, Max: number } } = {};
sizeRanges[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD] = { Min: 1, Max: 16384 };
sizeRanges[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3] = { Min: 1, Max: 16384 };
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-ec2/test/volume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ describe('volume', () => {
for (const testData of [
[EbsDeviceVolumeType.GENERAL_PURPOSE_SSD_GP3, 3000, 16000],
[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD, 100, 64000],
[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2, 100, 64000],
[EbsDeviceVolumeType.PROVISIONED_IOPS_SSD_IO2, 100, 256000],
]) {
const volumeType = testData[0] as EbsDeviceVolumeType;
const min = testData[1] as number;
Expand Down