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

(ec2): support throughput option in EBS volume #16213

Closed
1 of 2 tasks
jumic opened this issue Aug 24, 2021 · 12 comments · Fixed by #22441
Closed
1 of 2 tasks

(ec2): support throughput option in EBS volume #16213

jumic opened this issue Aug 24, 2021 · 12 comments · Fixed by #22441
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@jumic
Copy link
Contributor

jumic commented Aug 24, 2021

For EBS volumes with volume type GP3, the throughput in MiB/s can be configured. This is currently not supported in CDK.

Workaround: use escape hatches

Use Case

Set custom value for throughput, impacts performance and pricing.

Proposed Solution

The property is available in ebs volume and launchtemplate blockdevicemaping. It should be supported in both constructs.

Check if the property can be added to EbsDeviceOptionsBase or only to one of its subclasses (EbsDeviceOptions and EbsDeviceSnapshotOptions). Nothing specific is mentioned in the documentation.

Display a warning if throughput is defined for a volume type that does not support specifying a throughput. Display an error if a throughput value is specified that is not supported.

Other

Originally mentioned as comment in issue #12020.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@jumic jumic added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 24, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Aug 24, 2021
@njlynch njlynch added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Sep 3, 2021
@njlynch
Copy link
Contributor

njlynch commented Sep 3, 2021

Thanks for the feature request!

We welcome community contributions! If you are able, we encourage you to contribute. If you decide to contribute, please start an engineering discussion in this issue to ensure there is a commonly understood design before submitting code. This will minimize the number of review cycles and get your code merged faster.

@njlynch njlynch removed their assignment Sep 3, 2021
@jumic
Copy link
Contributor Author

jumic commented Sep 4, 2021

@njlynch I would propose the following implementation. Do you have any comments?
Could you please give me a short feedback to my questions? Thanks.

Add new property throughput (specified in MiB/s) to VolumeProps and EbsDeviceOptionsBase.
In Construct LaunchTemplate, throughput can be used when a volume is created and when it is restored. I did a short test with LaunchTemplate in combination with BlockDeviceVolume.ebsFromSnapshot(). Therefore, it should be correct to add it to interface EbsDeviceOptionsBase which is used for creating and restoring volumes.

readonly throughput?: number;

Add validation in validateProps().

  • Throw error if throughput is used for EbsDeviceVolumeType != GP3.
  • Throw error if value is not in supported range (Minimum value of 125. Maximum value of 1000)

Add validation in synthesizeBlockDeviceMappings().

  • Throw error if throughput is used for EbsDeviceVolumeType != GP3. Question: Should this be an error? For iops only a warning is added if it is used for unsupported volume types. However, this behavior is not consistent to validateProps().
  • Throw error if value is not in supported range (Minimum value of 125. Maximum value of 1000). Question: Should this be validated? The valid ranges for iops are not validated in this method. Again, this behavior is not consistent to validateProps().
  • Throw error if throughput is used in property BlockDeviceMapping for EC2 instances. This is currently not supported (see AWS::EC2::Instance - BlockDeviceMapping-Ebs-Throughput should support gp3 Throughput attribute aws-cloudformation/cloudformation-coverage-roadmap#824).

Add unit test cases and create integration tests that show Volume and LaunchTemplate with throughput can be deployed.

csumpter added a commit to csumpter/aws-cdk that referenced this issue Oct 10, 2022
csumpter added a commit to csumpter/aws-cdk that referenced this issue Oct 10, 2022
csumpter added a commit to csumpter/aws-cdk that referenced this issue Oct 10, 2022
csumpter added a commit to csumpter/aws-cdk that referenced this issue Oct 10, 2022
csumpter added a commit to csumpter/aws-cdk that referenced this issue Oct 10, 2022
csumpter added a commit to csumpter/aws-cdk that referenced this issue Oct 10, 2022
@jonyjalfon94
Copy link

jonyjalfon94 commented Oct 12, 2022

Hey, i just stumbled upon this issue while looking for a way of defining the throughput of GP3 volumes.
I understand from this PR that it's not currently supported via the aws_ec2.BlockDeviceVolume.ebs function.

Until this feature is merged, is there any workaround for defining it?

csumpter added a commit to csumpter/aws-cdk that referenced this issue Nov 3, 2022
csumpter added a commit to csumpter/aws-cdk that referenced this issue Nov 3, 2022
@csumpter
Copy link
Contributor

csumpter commented Nov 4, 2022

Hey, i just stumbled upon this issue while looking for a way of defining the throughput of GP3 volumes. I understand from this PR that it's not currently supported via the aws_ec2.BlockDeviceVolume.ebs function.

Until this feature is merged, is there any workaround for defining it?

You can do something like:

    interface ExtendedEbsDeviceOptions extends autoscaling.EbsDeviceOptions {
      throughput: number;
    }

    const asg = new autoscaling.AutoScalingGroup(this, "example", {
      blockDevices: [{
        deviceName: "/dev/sda1",
        volume: autoscaling.BlockDeviceVolume.ebs(1, {
         ...
          volumeType: autoscaling.EbsDeviceVolumeType.GP3,
          throughput: 125,
        } as ExtendedEbsDeviceOptions),
      }],
      ...
    })

This extends the type to include throughput where it will becomes rendered as Throughput by the cdk as it transforms that property.

There are other ways to get the throughput property rendered out with the resource but this is probably the easiest.

If you need to do get the compatibility for an ec2 volume you would do something like:

    interface Ec2VolumeExtended extends ec2.VolumeProps {
      throughput: number;
    }
    const volume = new ec2.Volume(this, "volume", {
      volumeType: ec2.EbsDeviceVolumeType.GP3,
      throughput: 125,
      ...
    } as Ec2VolumeExtended)

@mergify mergify bot closed this as completed in #22441 Nov 25, 2022
mergify bot pushed a commit that referenced this issue Nov 25, 2022
Adds support for the `throughput` property on GP3 volumes in both autoscaling and EC2 packages since their volume implementations are separate per the comment https://github.com/aws/aws-cdk/blob/master/packages/@aws-cdk/aws-autoscaling/lib/volume.ts#L1.

Change includes unit test coverage, integration test coverage on the autoscaling changes, and validation of the inputq to throughput. I was on the fence about whether to include the validation for synth time checking since as far as I can tell validation is not performed consistently across the CDK at synth time. Happy to modify that behavior pending reviewer feedback.

It was not obvious to me at first pass where similar integration test coverage that was added to the autoscaling package could be added to the EC2 package, so if the reviewer would like to see integration tests for GP3 volumes on in the EC2 package, would you mind providing a hint as to where that test might fit in the existing test paradigm?

Happy to break this change into two PRs -- one for EC2 and one for autoscaling.

closes: #16213

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@aldredb
Copy link

aldredb commented Dec 13, 2022

@csumpter I don't think the workaround works. This is my code:

export interface ExtendedEbsDeviceOptions extends aws_ec2.EbsDeviceOptions {
    throughput: number;
}
blockDevices: [{
        deviceName: '/dev/xvda',
        volume: aws_ec2.BlockDeviceVolume.ebs(3000, {
            deleteOnTermination: true,
            encrypted: false,
            iops: 16000,
            volumeType: EbsDeviceVolumeType.GP3,
            throughput: 1000,
          } as ExtendedEbsDeviceOptions),
      },
    ]

The throughput is not translated to CF template

@csumpter
Copy link
Contributor

@aldredb You should be able to upgrade to the latest aws-cdk release which now includes support/types for the throughput property.

@aldredb
Copy link

aldredb commented Dec 14, 2022

@csumpter Yep i used the 2.54.0 release. The throughput property is included in aws_autoscaling.EbsDeviceOptionsBase and aws_ec2.VolumeProps, but not aws_ec2.EbsDeviceOptionsBase, which the static function aws_ec2.BlockDeviceVolume.ebs takes as an argument.

@csumpter
Copy link
Contributor

csumpter commented Dec 14, 2022

@aldredb

You are correct that the throughput property is missing from EbsDeviceOptionsBase. Let's add a PR for that addition as it was not caught in the PR review, and I did not see that extra static method at the time I was writing the original PR.

In the meantime are you trying to create a EC2 instance in the example you gave?

@aldredb
Copy link

aldredb commented Dec 14, 2022

@csumpter
Copy link
Contributor

@csumpter

Yes. I'm trying to use this: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Instance.html#blockdevices

@aldredb I don't believe you can set a Throughput property on ebs block devices - see the CFN docs here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-blockdev-template.html

@tmokmss
Copy link
Contributor

tmokmss commented Dec 21, 2022

I also stumbled on this today for launch templates. Here's the workaround:

const launchTemplate = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
  // omitting other required properties
  blockDevices: [
    {
      deviceName: '/dev/xvda',
      volume: ec2.BlockDeviceVolume.ebs(100, {
        volumeType: ec2.EbsDeviceVolumeType.GP3,
      }),
    },
  ],
});
(launchTemplate.node.defaultChild as CfnResource).addPropertyOverride("LaunchTemplateData.BlockDeviceMappings.0.Ebs.Throughput", 200)

I'm not sure why LaunchTemplate ebs supports throughput (doc), whereas instance ebs not (doc).

edit)
I found the corresponding issue on CFn repo: aws-cloudformation/cloudformation-coverage-roadmap#824

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants