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

chore(rds): IO2 instance storage #29395

Merged
merged 6 commits into from
Mar 8, 2024
Merged

chore(rds): IO2 instance storage #29395

merged 6 commits into from
Mar 8, 2024

Conversation

badmintoncryer
Copy link
Contributor

@badmintoncryer badmintoncryer commented Mar 7, 2024

Issue # (if applicable)

Closes #29396.

Reason for this change

AWS RDS now supports IO2 instance storage but CDK cannot configure it yet.

Description of changes

  • Added IO2 storage type to the StorageType enum.
  • Set default IOPS to 1000, which is minimum value in the allowed IOPS range.

Description of how you validated changes

Added both unit and integ test

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Mar 7, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team March 7, 2024 03:00
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@github-actions github-actions bot added the feature-request A feature should be added or improved. label Mar 7, 2024
@badmintoncryer badmintoncryer changed the title feat(rds): IO2 storage type feat(rds): IO2 instance storage Mar 7, 2024
@badmintoncryer
Copy link
Contributor Author

Exemption Request
I think it is unnecessary to update README.md.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Mar 7, 2024
@badmintoncryer badmintoncryer marked this pull request as ready for review March 7, 2024 03:14
@badmintoncryer badmintoncryer changed the title feat(rds): IO2 instance storage chore(rds): IO2 instance storage Mar 7, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 7, 2024 03:27

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 7, 2024
Copy link
Contributor

@go-to-k go-to-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I made one minor comment.

Comment on lines 197 to 212
test('create DB instance with io2 instance storage', () => {
// WHEN
new rds.DatabaseInstance(stack, 'Instance', {
engine: rds.DatabaseInstanceEngine.MYSQL,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MEDIUM),
vpc,
storageType: rds.StorageType.IO2,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', {
Iops: 1000,
StorageType: 'io2',
});
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a similar test here, so it might be better to write it there.

https://github.com/go-to-k/aws-cdk/blob/0605a8b869aac6bccc9631fcea719895ca397f73/packages/aws-cdk-lib/aws-rds/test/instance.test.ts#L2011

Or maybe we could create tests that are separate from this test ('gp3 storage type') to check at once if the defaultIops method outputs iops for each storage type. (Leave the test ('gp3 storage type') to check the storageThroughput, and change the test name to another name related to gp3 and storageThroughput.)

For example:

  test.each([
    [rds.StorageType.STANDARD, 'standard', 2000, undefined],
    [rds.StorageType.GP2, 'gp2', 2000, undefined],
    [rds.StorageType.GP3, 'gp3', 2000, 2000],
    [rds.StorageType.IO1, 'io1', 2000, 2000],
    [rds.StorageType.IO1, 'io1', undefined, 1000],
    [rds.StorageType.IO2, 'io2', 2000, 2000],
    [rds.StorageType.IO2, 'io2', undefined, 1000],
  ])('storage type and IOPS for %s storage type', (inStorageType, outStorageType, inIops, outIops) => {
    new rds.DatabaseInstance(stack, 'Instance', {
      engine: rds.DatabaseInstanceEngine.mysql({ version: rds.MysqlEngineVersion.VER_8_0_30 }),
      vpc,
      storageType: inStorageType,
      iops: inIops,
    });

    Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', {
      StorageType: outStorageType,
      Iops: outIops ?? Match.absent(),
    });
  });

It may not be to your taste, which do you think would be better? Of course, the above code can be modified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@go-to-k Thank you for the excellent suggestion!! I replaced unit test and renamed existing gp3 test.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 7, 2024
@go-to-k
Copy link
Contributor

go-to-k commented Mar 7, 2024

Set default IOPS to 1000, which is minimum value in the allowed IOPS range.

By the way, what happens if we specify a value lower than 1000?
If CloudFormation fails, should we do that validation? (Or, Should we force to change the value to 1000?)

@badmintoncryer
Copy link
Contributor Author

badmintoncryer commented Mar 7, 2024

@go-to-k

Set default IOPS to 1000, which is minimum value in the allowed IOPS range.

By the way, what happens if we specify a value lower than 1000? If CloudFormation fails, should we do that validation? (Or, Should we force to change the value to 1000?)

Upon checking the behavior, it appears to fail during deployment.

integRdsInstanceIo2 | 9:52:23 PM | CREATE_FAILED        | AWS::RDS::DBInstance                        | Instance (InstanceC1063A87) Resource handler returned message: "Invalid iops value for engine name mysql and storage type io2: 500 (Service: Rds, Status Code: 400, Request ID: 2f806c31-840b-4774-86cf-26c3308a7631)" (RequestToken: d5833b29-5411-1712-8804-320a30504df9, HandlerErrorCode: InvalidRequest)

I think CDK should validate if the iops value within the range not only for io2 but also for other storage types.
(I believe it's better to raise an error rather than changing the value to a default, as this prevents users from recognizing the actual IOPS value.)

I'll create another issue about that and resolve it.
Is this approach acceptable to you?

@go-to-k
Copy link
Contributor

go-to-k commented Mar 7, 2024

@badmintoncryer Yes! I think so. I will approve this PR!

@badmintoncryer
Copy link
Contributor Author

@go-to-k Thank you Hero!!

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 7, 2024
Copy link
Contributor

@aaythapa aaythapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and to @go-to-k for a great review! I do agree we need validation for the different storage types, approving this for now

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 8, 2024
Copy link
Contributor

mergify bot commented Mar 8, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

1 similar comment
Copy link
Contributor

mergify bot commented Mar 8, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: ec556b9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 8b0dbb7 into aws:main Mar 8, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Mar 8, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@badmintoncryer badmintoncryer deleted the addIo2 branch March 9, 2024 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rds: support for IO2 instance storage
4 participants