Skip to content

Commit 99ca8dd

Browse files
authored
Merge pull request #37740 from atsalolikhin-spokeo/fix/20248
Add "io2" as a valid EBS volume type to EMR validation routine
2 parents a5ed8dc + f3bc323 commit 99ca8dd

File tree

8 files changed

+74
-16
lines changed

8 files changed

+74
-16
lines changed

.changelog/37740.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```release-note:enhancement
2+
resource/aws_emr_cluster: Support `io2` as a valid value for `ebs_config.type`
3+
```
4+
5+
```release-note:enhancement
6+
resource/aws_emr_instance_fleet: Support `io2` as a valid value for `instance_type_configs.ebs_config.type`
7+
```
8+
9+
```release-note:enhancement
10+
resource/aws_emr_instance_group: Support `io2` as a valid value for `instance_type_configs.ebs_config.type`
11+
```
12+
13+
```release-note:bug
14+
resource/aws_emr_instance_group: Properly send an `instance_count` value of `0` on create when configured
15+
```

internal/service/emr/instance_group.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ func resourceInstanceGroupCreate(ctx context.Context, d *schema.ResourceData, me
185185
}
186186
}
187187

188-
if v, ok := d.GetOk(names.AttrInstanceCount); ok {
189-
groupConfig.InstanceCount = aws.Int32(int32(v.(int)))
188+
if v := d.GetRawConfig().GetAttr(names.AttrInstanceCount); v.IsKnown() && !v.IsNull() {
189+
v, _ := v.AsBigFloat().Int64()
190+
groupConfig.InstanceCount = aws.Int32(int32(v))
190191
} else {
191192
groupConfig.InstanceCount = aws.Int32(1)
192193
}

internal/service/emr/instance_group_test.go

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ func TestAccEMRInstanceGroup_basic(t *testing.T) {
3333
Steps: []resource.TestStep{
3434
{
3535
Config: testAccInstanceGroupConfig_basic(rName),
36-
Check: resource.ComposeTestCheckFunc(
36+
Check: resource.ComposeAggregateTestCheckFunc(
3737
testAccCheckInstanceGroupExists(ctx, resourceName, &v),
3838
resource.TestCheckResourceAttr(resourceName, "autoscaling_policy", ""),
3939
resource.TestCheckResourceAttr(resourceName, "bid_price", ""),
4040
resource.TestCheckResourceAttr(resourceName, "ebs_optimized", acctest.CtFalse),
41+
resource.TestCheckResourceAttr(resourceName, names.AttrInstanceCount, acctest.Ct1),
4142
),
4243
},
4344
{
@@ -258,8 +259,8 @@ func TestAccEMRInstanceGroup_autoScalingPolicy(t *testing.T) {
258259
}
259260

260261
// Confirm we can scale down the instance count.
261-
// Regression test for https://github.com/hashicorp/terraform-provider-aws/issues/1264
262-
func TestAccEMRInstanceGroup_instanceCount(t *testing.T) {
262+
// See https://github.com/hashicorp/terraform-provider-aws/issues/1264.
263+
func TestAccEMRInstanceGroup_instanceCountDecrease(t *testing.T) {
263264
ctx := acctest.Context(t)
264265
var v awstypes.InstanceGroup
265266
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
@@ -272,8 +273,11 @@ func TestAccEMRInstanceGroup_instanceCount(t *testing.T) {
272273
CheckDestroy: acctest.CheckDestroyNoop,
273274
Steps: []resource.TestStep{
274275
{
275-
Config: testAccInstanceGroupConfig_basic(rName),
276-
Check: testAccCheckInstanceGroupExists(ctx, resourceName, &v),
276+
Config: testAccInstanceGroupConfig_instanceCount(rName, 2),
277+
Check: resource.ComposeTestCheckFunc(
278+
testAccCheckInstanceGroupExists(ctx, resourceName, &v),
279+
resource.TestCheckResourceAttr(resourceName, names.AttrInstanceCount, acctest.Ct2),
280+
),
277281
},
278282
{
279283
ResourceName: resourceName,
@@ -283,8 +287,43 @@ func TestAccEMRInstanceGroup_instanceCount(t *testing.T) {
283287
ImportStateVerifyIgnore: []string{names.AttrStatus},
284288
},
285289
{
286-
Config: testAccInstanceGroupConfig_zeroCount(rName),
287-
Check: testAccCheckInstanceGroupExists(ctx, resourceName, &v),
290+
Config: testAccInstanceGroupConfig_instanceCount(rName, 0),
291+
Check: resource.ComposeTestCheckFunc(
292+
testAccCheckInstanceGroupExists(ctx, resourceName, &v),
293+
resource.TestCheckResourceAttr(resourceName, names.AttrInstanceCount, acctest.Ct0),
294+
),
295+
},
296+
},
297+
})
298+
}
299+
300+
// Confirm we can create with a 0 instance count.
301+
// See https://github.com/hashicorp/terraform-provider-aws/issues/38837.
302+
func TestAccEMRInstanceGroup_instanceCountCreateZero(t *testing.T) {
303+
ctx := acctest.Context(t)
304+
var v awstypes.InstanceGroup
305+
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
306+
resourceName := "aws_emr_instance_group.test"
307+
308+
resource.ParallelTest(t, resource.TestCase{
309+
PreCheck: func() { acctest.PreCheck(ctx, t) },
310+
ErrorCheck: acctest.ErrorCheck(t, names.EMRServiceID),
311+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
312+
CheckDestroy: acctest.CheckDestroyNoop,
313+
Steps: []resource.TestStep{
314+
{
315+
Config: testAccInstanceGroupConfig_instanceCount(rName, 0),
316+
Check: resource.ComposeTestCheckFunc(
317+
testAccCheckInstanceGroupExists(ctx, resourceName, &v),
318+
resource.TestCheckResourceAttr(resourceName, names.AttrInstanceCount, acctest.Ct0),
319+
),
320+
},
321+
{
322+
ResourceName: resourceName,
323+
ImportState: true,
324+
ImportStateIdFunc: testAccInstanceGroupResourceImportStateIdFunc(resourceName),
325+
ImportStateVerify: true,
326+
ImportStateVerifyIgnore: []string{names.AttrStatus},
288327
},
289328
},
290329
})
@@ -518,12 +557,12 @@ resource "aws_emr_instance_group" "test" {
518557
`, o))
519558
}
520559

521-
func testAccInstanceGroupConfig_zeroCount(rName string) string {
522-
return acctest.ConfigCompose(testAccInstanceGroupConfig_base(rName), `
560+
func testAccInstanceGroupConfig_instanceCount(rName string, count int) string {
561+
return acctest.ConfigCompose(testAccInstanceGroupConfig_base(rName), fmt.Sprintf(`
523562
resource "aws_emr_instance_group" "test" {
524563
cluster_id = aws_emr_cluster.test.id
525-
instance_count = 0
564+
instance_count = %[1]d
526565
instance_type = "c4.large"
527566
}
528-
`)
567+
`, count))
529568
}

internal/service/emr/managed_scaling_policy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func resourceManagedScalingPolicyDelete(ctx context.Context, d *schema.ResourceD
151151
})
152152

153153
if tfawserr.ErrMessageContains(err, errCodeValidationException, "A job flow that is shutting down, terminated, or finished may not be modified") ||
154+
tfawserr.ErrMessageContains(err, errCodeValidationException, "is not valid") ||
154155
errs.IsAErrorMessageContains[*awstypes.InvalidRequestException](err, "does not exist") {
155156
return diags
156157
}
@@ -174,6 +175,7 @@ func findManagedScalingPolicy(ctx context.Context, conn *emr.Client, input *emr.
174175
output, err := conn.GetManagedScalingPolicy(ctx, input)
175176

176177
if tfawserr.ErrMessageContains(err, errCodeValidationException, "A job flow that is shutting down, terminated, or finished may not be modified") ||
178+
tfawserr.ErrMessageContains(err, errCodeValidationException, "is not valid") ||
177179
errs.IsAErrorMessageContains[*awstypes.InvalidRequestException](err, "does not exist") {
178180
return nil, &retry.NotFoundError{
179181
LastError: err,

internal/service/emr/validate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func validEBSVolumeType() schema.SchemaValidateFunc {
3030
"gp3",
3131
"gp2",
3232
"io1",
33+
"io2",
3334
"standard",
3435
"st1",
3536
"sc1",

website/docs/cdktf/python/r/emr_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ The launch specification for Spot instances in the fleet, which determines the d
583583

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

website/docs/cdktf/typescript/r/emr_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ The launch specification for Spot instances in the fleet, which determines the d
757757

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

website/docs/r/emr_cluster.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ The launch specification for Spot instances in the fleet, which determines the d
734734

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

0 commit comments

Comments
 (0)