Skip to content

Commit dc030fd

Browse files
committed
feat(ec2): support throughput on LaunchTemplate EBS volumes
This support was simply not included in ec2 when it was added to autoscaling in aws#22441. I have copied that PR's implementation implementation to ec2 and similarly adapted its tests. Fixes aws#24341.
1 parent 439feaf commit dc030fd

File tree

9 files changed

+198
-60
lines changed

9 files changed

+198
-60
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.assets.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/aws-cdk-ec2-lt-metadata-1.template.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@
159159
"Type": "AWS::EC2::LaunchTemplate",
160160
"Properties": {
161161
"LaunchTemplateData": {
162+
"BlockDeviceMappings": [
163+
{
164+
"DeviceName": "/dev/xvda",
165+
"Ebs": {
166+
"Throughput": 250,
167+
"VolumeSize": 15,
168+
"VolumeType": "gp3"
169+
}
170+
}
171+
],
162172
"MetadataOptions": {
163173
"HttpEndpoint": "enabled",
164174
"HttpProtocolIpv6": "enabled",
@@ -211,8 +221,7 @@
211221
}
212222
]
213223
}
214-
],
215-
"VersionDescription": "test template v1"
224+
]
216225
}
217226
},
218227
"sg2860DD91F": {

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/manifest.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.js.snapshot/tree.json

+63-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.launch-template.ts

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ const lt = new ec2.LaunchTemplate(stack, 'LT', {
2323
httpTokens: ec2.LaunchTemplateHttpTokens.REQUIRED,
2424
instanceMetadataTags: true,
2525
securityGroup: sg1,
26+
blockDevices: [{
27+
deviceName: '/dev/xvda',
28+
volume: ec2.BlockDeviceVolume.ebs(15, {
29+
volumeType: ec2.EbsDeviceVolumeType.GP3,
30+
throughput: 250,
31+
}),
32+
}],
2633
});
2734

2835
const sg2 = new ec2.SecurityGroup(stack, 'sg2', {

packages/aws-cdk-lib/aws-ec2/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,33 @@ new ec2.Instance(this, 'Instance', {
16031603

16041604
```
16051605

1606+
To specify the throughput value for `gp3` volumes, use the `throughput` property:
1607+
1608+
```ts
1609+
declare const vpc: ec2.Vpc;
1610+
declare const instanceType: ec2.InstanceType;
1611+
declare const machineImage: ec2.IMachineImage;
1612+
1613+
const kmsKey = new Key(this, 'KmsKey')
1614+
1615+
new ec2.Instance(this, 'Instance', {
1616+
vpc,
1617+
instanceType,
1618+
machineImage,
1619+
1620+
// ...
1621+
1622+
blockDevices: [
1623+
{
1624+
deviceName: '/dev/sda1',
1625+
volume: ec2.BlockDeviceVolume.ebs(100, {
1626+
volumeType: ec2.EbsDeviceVolumeType.GP3,
1627+
throughput: 250,
1628+
}),
1629+
},
1630+
],
1631+
});
1632+
16061633
#### EBS Optimized Instances
16071634

16081635
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.

0 commit comments

Comments
 (0)