From 6e9b7cf5bb98eba00179311f003ab7c4876619dd Mon Sep 17 00:00:00 2001 From: Gaylord Mazelier Date: Fri, 18 Dec 2020 17:34:18 +0100 Subject: [PATCH] Set min_vcpus to 0 if not defined for EC2 or SPOT --- aws/resource_aws_batch_compute_environment.go | 2 ++ website/docs/r/batch_compute_environment.html.markdown | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_batch_compute_environment.go b/aws/resource_aws_batch_compute_environment.go index 8664edb7475..9883abd4312 100644 --- a/aws/resource_aws_batch_compute_environment.go +++ b/aws/resource_aws_batch_compute_environment.go @@ -275,6 +275,8 @@ func resourceAwsBatchComputeEnvironmentCreate(d *schema.ResourceData, meta inter } if v, ok := computeResource["min_vcpus"]; ok && v.(int) > 0 { input.ComputeResources.MinvCpus = aws.Int64(int64(v.(int))) + } else if computeResourceType == batch.CRTypeEc2 || computeResourceType == batch.CRTypeSpot { + input.ComputeResources.MinvCpus = aws.Int64(0) } if v, ok := computeResource["spot_iam_fleet_role"]; ok && len(v.(string)) > 0 { input.ComputeResources.SpotIamFleetRole = aws.String(v.(string)) diff --git a/website/docs/r/batch_compute_environment.html.markdown b/website/docs/r/batch_compute_environment.html.markdown index 2e70e16ed0f..cc3ddd5c4a3 100644 --- a/website/docs/r/batch_compute_environment.html.markdown +++ b/website/docs/r/batch_compute_environment.html.markdown @@ -171,7 +171,7 @@ resource "aws_batch_compute_environment" "sample" { * `instance_type` - (Optional) A list of instance types that may be launched. This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified. * `launch_template` - (Optional) The launch template to use for your compute resources. See details below. This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified. * `max_vcpus` - (Required) The maximum number of EC2 vCPUs that an environment can reach. -* `min_vcpus` - (Optional) The minimum number of EC2 vCPUs that an environment should maintain. This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified. +* `min_vcpus` - (Optional) The minimum number of EC2 vCPUs that an environment should maintain. For `EC2` or `SPOT` compute environments, if the parameter is not explicitly defined, a `0` default value will be set. This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified. * `security_group_ids` - (Required) A list of EC2 security group that are associated with instances launched in the compute environment. * `spot_iam_fleet_role` - (Optional) The Amazon Resource Name (ARN) of the Amazon EC2 Spot Fleet IAM role applied to a SPOT compute environment. This parameter is required for SPOT compute environments. This parameter isn't applicable to jobs running on Fargate resources, and shouldn't be specified. * `subnets` - (Required) A list of VPC subnets into which the compute resources are launched.