From 937ca7c71e0cb0db32891ba7ae73dc7eba6f2da0 Mon Sep 17 00:00:00 2001 From: "justin.miron" Date: Mon, 10 Jul 2023 13:16:29 -0500 Subject: [PATCH] feat(ec2): Add Throughput to EBSBlockDevice Newer generation EBS block devices allow passing in a throughput parameter similar to IOPs. This adds that field to EBSBlockDevice and pipes it through to the AWS API request similar to IOPs. Signed-off-by: justin.miron Signed-off-by: Maximilian Blatt (external expert on behalf of DB Netz) Co-authored-by: Maximilian Blatt (external expert on behalf of DB Netz) (rebase and change to "Throughput") --- apis/ec2/manualv1alpha1/common.go | 8 ++++++++ apis/ec2/manualv1alpha1/zz_generated.deepcopy.go | 5 +++++ package/crds/ec2.aws.crossplane.io_instances.yaml | 9 +++++++++ pkg/clients/ec2/instance.go | 1 + pkg/clients/ec2/instance_test.go | 2 ++ 5 files changed, 25 insertions(+) diff --git a/apis/ec2/manualv1alpha1/common.go b/apis/ec2/manualv1alpha1/common.go index 9b59d9bef5..6add439baa 100644 --- a/apis/ec2/manualv1alpha1/common.go +++ b/apis/ec2/manualv1alpha1/common.go @@ -172,6 +172,14 @@ type EBSBlockDevice struct { // it is not used in requests to create gp2, st1, sc1, or standard volumes. IOps *int32 `json:"iops,omitempty"` + // The throughput that the volume supports, in MiB/s. + // + // Constraints: Up to 1,000MiB/s for gp3 volumes. + // + // Condition: This parameter is optional and only used to create gp3 volumes; + // it is not used in requests to create gp2, st1, sc1, io1, or standard volumes. + Throughput *int32 `json:"throughput,omitempty"` + // Identifier (key ID, key alias, ID ARN, or alias ARN) for a customer managed // CMK under which the EBS volume is encrypted. // diff --git a/apis/ec2/manualv1alpha1/zz_generated.deepcopy.go b/apis/ec2/manualv1alpha1/zz_generated.deepcopy.go index 243b2ea7ac..3525007b4c 100644 --- a/apis/ec2/manualv1alpha1/zz_generated.deepcopy.go +++ b/apis/ec2/manualv1alpha1/zz_generated.deepcopy.go @@ -184,6 +184,11 @@ func (in *EBSBlockDevice) DeepCopyInto(out *EBSBlockDevice) { *out = new(int32) **out = **in } + if in.Throughput != nil { + in, out := &in.Throughput, &out.Throughput + *out = new(int32) + **out = **in + } if in.KmsKeyID != nil { in, out := &in.KmsKeyID, &out.KmsKeyID *out = new(string) diff --git a/package/crds/ec2.aws.crossplane.io_instances.yaml b/package/crds/ec2.aws.crossplane.io_instances.yaml index bab05edf90..7e0df80d5e 100644 --- a/package/crds/ec2.aws.crossplane.io_instances.yaml +++ b/package/crds/ec2.aws.crossplane.io_instances.yaml @@ -239,6 +239,15 @@ spec: snapshotId: description: The ID of the snapshot. type: string + throughput: + description: "The throughput that the volume supports, + in MiB/s. \n Constraints: Up to 1,000MiB/s for gp3 + volumes. \n Condition: This parameter is optional + and only used to create gp3 volumes; it is not used + in requests to create gp2, st1, sc1, io1, or standard + volumes." + format: int32 + type: integer volumeSize: description: "The size of the volume, in GiB. \n Default: If you're creating the volume from a snapshot and diff --git a/pkg/clients/ec2/instance.go b/pkg/clients/ec2/instance.go index c8d06e69c6..e7b3796f6a 100644 --- a/pkg/clients/ec2/instance.go +++ b/pkg/clients/ec2/instance.go @@ -225,6 +225,7 @@ func GenerateEC2BlockDeviceMappings(mappings []manualv1alpha1.BlockDeviceMapping DeleteOnTermination: bm.EBS.DeleteOnTermination, Encrypted: bm.EBS.Encrypted, Iops: bm.EBS.IOps, + Throughput: bm.EBS.Throughput, KmsKeyId: bm.EBS.KmsKeyID, SnapshotId: bm.EBS.SnapshotID, VolumeSize: bm.EBS.VolumeSize, diff --git a/pkg/clients/ec2/instance_test.go b/pkg/clients/ec2/instance_test.go index 444afc6fc4..c6ff5d963d 100644 --- a/pkg/clients/ec2/instance_test.go +++ b/pkg/clients/ec2/instance_test.go @@ -574,6 +574,7 @@ func TestGenerateEC2RunInstancesInput(t *testing.T) { DeleteOnTermination: aws.Bool(false), Encrypted: aws.Bool(false), IOps: aws.Int32(1), + Throughput: aws.Int32(100), KmsKeyID: aws.String(keyName), SnapshotID: aws.String(snapshotID), VolumeSize: aws.Int32(1), @@ -723,6 +724,7 @@ func TestGenerateEC2RunInstancesInput(t *testing.T) { DeleteOnTermination: aws.Bool(false), Encrypted: aws.Bool(false), Iops: aws.Int32(1), + Throughput: aws.Int32(100), KmsKeyId: aws.String(keyName), SnapshotId: aws.String(snapshotID), VolumeSize: aws.Int32(1),