Skip to content

Commit 183cc95

Browse files
authored
Merge pull request #27207 from ekini/fix/compute_environment_ec2_configuration
Fix MaxItems for batch/compute_environments ec2_configuration
2 parents 5afc4cf + 4a6c782 commit 183cc95

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.changelog/27207.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/aws_batch_compute_environment: Allow a maximum of 2 `compute_resources.ec2_configuration`s
3+
```

internal/service/batch/compute_environment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func ResourceComputeEnvironment() *schema.Resource {
9191
Optional: true,
9292
Computed: true,
9393
ForceNew: true,
94-
MaxItems: 1,
94+
MaxItems: 2,
9595
Elem: &schema.Resource{
9696
Schema: map[string]*schema.Schema{
9797
"image_id_override": {

internal/service/batch/compute_environment_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -1036,9 +1036,11 @@ func TestAccBatchComputeEnvironment_ec2Configuration(t *testing.T) {
10361036
resource.TestCheckResourceAttrPair(resourceName, "compute_resources.0.instance_role", instanceProfileResourceName, "arn"),
10371037
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.instance_type.#", "1"),
10381038
resource.TestCheckTypeSetElemAttr(resourceName, "compute_resources.0.instance_type.*", "optimal"),
1039-
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.ec2_configuration.#", "1"),
1039+
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.ec2_configuration.#", "2"),
10401040
resource.TestCheckResourceAttrSet(resourceName, "compute_resources.0.ec2_configuration.0.image_id_override"),
10411041
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.ec2_configuration.0.image_type", "ECS_AL2"),
1042+
resource.TestCheckResourceAttrSet(resourceName, "compute_resources.0.ec2_configuration.1.image_id_override"),
1043+
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.ec2_configuration.1.image_type", "ECS_AL2_NVIDIA"),
10421044
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.max_vcpus", "16"),
10431045
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.min_vcpus", "0"),
10441046
resource.TestCheckResourceAttr(resourceName, "compute_resources.0.security_group_ids.#", "1"),
@@ -2461,11 +2463,17 @@ resource "aws_batch_compute_environment" "test" {
24612463
compute_resources {
24622464
instance_role = aws_iam_instance_profile.ecs_instance.arn
24632465
instance_type = ["optimal"]
2466+
24642467
ec2_configuration {
24652468
image_id_override = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
24662469
image_type = "ECS_AL2"
24672470
}
24682471
2472+
ec2_configuration {
2473+
image_id_override = data.aws_ami.amzn-ami-minimal-hvm-ebs.id
2474+
image_type = "ECS_AL2_NVIDIA"
2475+
}
2476+
24692477
max_vcpus = 16
24702478
min_vcpus = 0
24712479

0 commit comments

Comments
 (0)