Repository: kubernetes-sigs/aws-ebs-csi-driver (Go)

Issue:
Throughput parameter doesn't work
/kind bug

**What happened?**
Throughput parameter on StorageClass not being implemented for dynamic provisioning.

**What you expected to happen?**
I was using a `gp3` EBS type and specified throughput as 250Mb/s, and it came up as 125Mb/s.

**How to reproduce it (as minimally and precisely as possible)?**
Define a StorageClass as follows:
```
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: somename
parameters:
  encrypted: "true"
  iops: "5000"
  kmsKeyId: "kmskeyId"
  throughput: "250"
provisioner: ebs.csi.aws.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
```
  
**Anything else we need to know?**:

**Environment**
- Kubernetes version (use `kubectl version`): 
```
Client Version: v1.24.10-eks-48e63af
Kustomize Version: v4.5.4
Server Version: v1.25.8-eks-ec5523e
```
- Driver version: v1.18.0



Discussion:
Thanks for reporting this. We will fix it. In the meantime, you could use a workaround by specifying the volume type in the parameters.

```
type: "gp3"
```

That will provision the correct throughput. 



Patch:
diff --git a/pkg/cloud/cloud.go b/pkg/cloud/cloud.go
index 9e61c93b5f..0e18ccb64b 100644
--- a/pkg/cloud/cloud.go
+++ b/pkg/cloud/cloud.go
@@ -393,7 +393,7 @@ func (c *cloud) CreateDisk(ctx context.Context, volumeName string, diskOptions *
 	if iops > 0 {
 		requestInput.Iops = aws.Int64(iops)
 	}
-	if throughput > 0 && diskOptions.VolumeType == VolumeTypeGP3 {
+	if throughput > 0 {
 		requestInput.Throughput = aws.Int64(throughput)
 	}
 	snapshotID := diskOptions.SnapshotID


Test patch:
diff --git a/pkg/cloud/cloud_test.go b/pkg/cloud/cloud_test.go
index 2c2c9a8a03..e98d61536e 100644
--- a/pkg/cloud/cloud_test.go
+++ b/pkg/cloud/cloud_test.go
@@ -175,7 +175,8 @@ func TestCreateDisk(t *testing.T) {
 				AvailabilityZone: defaultZone,
 			},
 			expCreateVolumeInput: &ec2.CreateVolumeInput{
-				Iops: aws.Int64(3000),
+				Iops:       aws.Int64(3000),
+				Throughput: aws.Int64(125),
 			},
 			expErr: nil,
 		},
@@ -551,6 +552,24 @@ func TestCreateDisk(t *testing.T) {
 			},
 			expErr: fmt.Errorf("could not attach tags to volume: vol-test. CreateTags generic error"),
 		},
+		{
+			name:       "success: create default volume with throughput",
+			volumeName: "vol-test-name",
+			diskOptions: &DiskOptions{
+				CapacityBytes: util.GiBToBytes(1),
+				Tags:          map[string]string{VolumeNameTagKey: "vol-test", AwsEbsDriverTagKey: "true"},
+				Throughput:    250,
+			},
+			expCreateVolumeInput: &ec2.CreateVolumeInput{
+				Throughput: aws.Int64(250),
+			},
+			expDisk: &Disk{
+				VolumeID:         "vol-test",
+				CapacityGiB:      1,
+				AvailabilityZone: defaultZone,
+			},
+			expErr: nil,
+		},
 	}
 
 	for _, tc := range testCases {
@@ -1961,8 +1980,8 @@ func (m *eqCreateVolumeMatcher) Matches(x interface{}) bool {
 	if input == nil {
 		return false
 	}
-	// Compare only IOPS for now
-	ret := reflect.DeepEqual(m.expected.Iops, input.Iops)
+	// TODO: Check all inputs
+	ret := reflect.DeepEqual(m.expected.Iops, input.Iops) && reflect.DeepEqual(m.expected.Throughput, input.Throughput)
 	return ret
 }