Skip to content

Commit

Permalink
feat(ec2): support throughput on LaunchTemplate EBS volumes
Browse files Browse the repository at this point in the history
This support was simply not included in ec2 when it was added to
autoscaling in #22441. I have copied that PR's implementation
implementation to ec2 and similarly adapted its tests.

Fixes #24341.
  • Loading branch information
isker committed Jul 31, 2024
1 parent 439feaf commit 5899b6b
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 60 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@
"Type": "AWS::EC2::LaunchTemplate",
"Properties": {
"LaunchTemplateData": {
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Throughput": 250,
"VolumeSize": 15,
"VolumeType": "gp3"
}
}
],
"MetadataOptions": {
"HttpEndpoint": "enabled",
"HttpProtocolIpv6": "enabled",
Expand Down Expand Up @@ -211,8 +221,7 @@
}
]
}
],
"VersionDescription": "test template v1"
]
}
},
"sg2860DD91F": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const lt = new ec2.LaunchTemplate(stack, 'LT', {
httpTokens: ec2.LaunchTemplateHttpTokens.REQUIRED,
instanceMetadataTags: true,
securityGroup: sg1,
blockDevices: [{
deviceName: '/dev/xvda',
volume: ec2.BlockDeviceVolume.ebs(15, {
volumeType: ec2.EbsDeviceVolumeType.GP3,
throughput: 250,
}),
}],
});

const sg2 = new ec2.SecurityGroup(stack, 'sg2', {
Expand Down
27 changes: 27 additions & 0 deletions packages/aws-cdk-lib/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,33 @@ new ec2.Instance(this, 'Instance', {

```

To specify the throughput value for `gp3` volumes, use the `throughput` property:

```ts
declare const vpc: ec2.Vpc;
declare const instanceType: ec2.InstanceType;
declare const machineImage: ec2.IMachineImage;

const kmsKey = new Key(this, 'KmsKey')

new ec2.Instance(this, 'Instance', {
vpc,
instanceType,
machineImage,

// ...

blockDevices: [
{
deviceName: '/dev/sda1',
volume: ec2.BlockDeviceVolume.ebs(100, {
volumeType: ec2.EbsDeviceVolumeType.GP3,
throughput: 250,
}),
},
],
});

#### EBS Optimized Instances

An Amazon EBSoptimized instance uses an optimized configuration stack and provides additional, dedicated capacity for Amazon EBS I/O. This optimization provides the best performance for your EBS volumes by minimizing contention between Amazon EBS I/O and other traffic from your instance.
Expand Down
Loading

0 comments on commit 5899b6b

Please sign in to comment.