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

Add gp3 volume support to EMR cluster EBS config #25668

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/25668.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_emr_cluster: Add `gp3` EBS volume support
```

```release-note:enhancement
resource/aws_emr_cluster: Add `core_instance_group.ebs_config.throughput` and `master_instance_group.ebs_config.throughput` arguments
```
22 changes: 22 additions & 0 deletions internal/service/emr/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ func ResourceCluster() *schema.Resource {
Required: true,
ForceNew: true,
},
"throughput": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"type": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -393,6 +398,11 @@ func ResourceCluster() *schema.Resource {
Required: true,
ForceNew: true,
},
"throughput": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
},
"type": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -1666,6 +1676,9 @@ func flattenEBSConfig(ebsBlockDevices []*emr.EbsBlockDevice) *schema.Set {
if ebs.VolumeSpecification.SizeInGB != nil {
ebsAttrs["size"] = int(aws.Int64Value(ebs.VolumeSpecification.SizeInGB))
}
if ebs.VolumeSpecification.Throughput != nil {
ebsAttrs["throughput"] = aws.Int64Value(ebs.VolumeSpecification.Throughput)
}
if ebs.VolumeSpecification.VolumeType != nil {
ebsAttrs["type"] = aws.StringValue(ebs.VolumeSpecification.VolumeType)
}
Expand Down Expand Up @@ -1814,6 +1827,9 @@ func expandEBSConfig(configAttributes map[string]interface{}, config *emr.Instan
VolumeType: aws.String(rawEbsConfig["type"].(string)),
},
}
if v, ok := rawEbsConfig["throughput"].(int); ok && v != 0 {
ebsBlockDeviceConfig.VolumeSpecification.Throughput = aws.Int64(int64(v))
}
if v, ok := rawEbsConfig["iops"].(int); ok && v != 0 {
ebsBlockDeviceConfig.VolumeSpecification.Iops = aws.Int64(int64(v))
}
Expand Down Expand Up @@ -1909,6 +1925,9 @@ func resourceClusterEBSHashConfig(v interface{}) int {
buf.WriteString(fmt.Sprintf("%d-", m["size"].(int)))
buf.WriteString(fmt.Sprintf("%s-", m["type"].(string)))
buf.WriteString(fmt.Sprintf("%d-", m["volumes_per_instance"].(int)))
if v, ok := m["throughput"].(int); ok && v != 0 {
buf.WriteString(fmt.Sprintf("%d-", v))
}
if v, ok := m["iops"].(int); ok && v != 0 {
buf.WriteString(fmt.Sprintf("%d-", v))
}
Expand Down Expand Up @@ -2092,6 +2111,9 @@ func expandEBSConfiguration(ebsConfigurations []interface{}) *emr.EbsConfigurati
VolumeType: aws.String(cfg["type"].(string)),
},
}
if v, ok := cfg["throughput"].(int); ok && v != 0 {
ebsBlockDeviceConfig.VolumeSpecification.Throughput = aws.Int64(int64(v))
}
if v, ok := cfg["iops"].(int); ok && v != 0 {
ebsBlockDeviceConfig.VolumeSpecification.Iops = aws.Int64(int64(v))
}
Expand Down
3 changes: 2 additions & 1 deletion internal/service/emr/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3560,7 +3560,8 @@ resource "aws_emr_cluster" "test" {
}
ebs_config {
size = 50
type = "gp2"
throughput = 500
type = "gp3"
volumes_per_instance = %[2]d
}
}
Expand Down
1 change: 1 addition & 0 deletions internal/service/emr/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func validCustomAMIID(v interface{}, k string) (ws []string, errors []error) {

func validEBSVolumeType() schema.SchemaValidateFunc {
return validation.StringInSlice([]string{
"gp3",
"gp2",
"io1",
"standard",
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/emr_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ The launch specification for Spot instances in the fleet, which determines the d

* `iops` - (Optional) Number of I/O operations per second (IOPS) that the volume supports.
* `size` - (Required) Volume size, in gibibytes (GiB).
* `type` - (Required) Volume type. Valid options are `gp2`, `io1`, `standard` and `st1`. See [EBS Volume Types](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html).
* `type` - (Required) Volume type. Valid options are `gp3`, `gp2`, `io1`, `standard` and `st1`. See [EBS Volume Types](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html).
* `throughput` - (Optional) The throughput, in mebibyte per second (MiB/s).
* `volumes_per_instance` - (Optional) Number of EBS volumes with this configuration to attach to each EC2 instance in the instance group (default is 1).

### ec2_attributes
Expand Down