Skip to content

Commit

Permalink
fix(ec2): max iops value for io2 EBS volume is wrong (#28695)
Browse files Browse the repository at this point in the history
The max value of `iops` for `io2` EBS volume is wrong. And I fixed the reference URL.

- 64000 -> 256000

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-volume.html#cfn-ec2-volume-iops

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
go-to-k authored Jan 17, 2024
1 parent 2b59ed1 commit a30a205
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit a30a205

Please sign in to comment.