Terraform-provider-aws: resource aws_batch_compute_environment gives error if optional desired_vcpus is not set

Created on 27 May 2018  ·  9Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.7
+ provider.aws v1.19.0

Affected Resource(s)

  • aws_batch_compute_environment

Terraform Configuration Files


resource aws_batch_compute_environment batch_env {
  compute_environment_name = "postgres-loader"
  service_role             = "arn:aws:iam::XXXXXXXXXX:role/service-role/AWSBatchServiceRole"
  type                     = "MANAGED"

  compute_resources {
    type          = "EC2"
    instance_role = "arn:aws:iam::XXXXXXXXXX:instance-profile/ecsInstanceRole"
    instance_type = ["optimal"]
    min_vcpus     = 1
    max_vcpus     = 32

    subnets            = ["${local.subnet_ids}"]
    security_group_ids = ["${aws_security_group.batch.id}"]

    tags {
      Name        = "insights"
      Environment = "production"
    }
  }
}

Debug Output

https://gist.github.com/jasantunes/397662245f1877848215e69182c1ecf4

Panic Output

N/A.

Expected Behavior

It should've accepted the min_vcpu and max_vcpu parameters and infer nothing about parameter desired_vcpus that was not set and is optional.

Actual Behavior

Error: Error applying plan:

1 error(s) occurred:

* aws_batch_compute_environment.batch_env: 1 error(s) occurred:

* aws_batch_compute_environment.batch_env: : Error executing request, Exception : desiredvCpus should be between minvCpus and maxvCpus, RequestId: 06362c77-6133-11e8-8122-077fbc0c56df
    status code: 400, request id: 06362c77-6133-11e8-8122-077fbc0c56df

Steps to Reproduce

Create a aws_batch_compute_environment resource without setting desired_vcpus parameter in compute_resources.

Important Factoids

N/A.

References

bug servicbatch

Most helpful comment

I have found that ignoring compute_resources.0.desired_vcpus works.

All 9 comments

This also impacts updating batch if the desired_vcpus is set. It doesn't allow it to be optional. If ommitted it resets to 0, and if present (but the ignore_changes lifecycle is set for desired_vcpus) it doesn't ignore it.

I've started to take a look at the code, but I'm a little stumped.

Hi, same issue as described by @andylockran . This is quite annoying especially because we have no way to skip this setting (even ignore_changes doesn't works as expected...)

I think I may have a workaround; though I’ve upgraded to 0.12.10 so it’s potentially a different solution.

I’ll share the 0.12.10 solution and can see if that works on 0.11.0

Sent from my iPhone

On 8 Nov 2019, at 13:45, David Galichet notifications@github.com wrote:


Hi, same issue as described by @andylockran . This is quite annoying especially because we have no way to skip this setting (even ignore_changes doesn't works as expected...)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

I have found that ignoring compute_resources.0.desired_vcpus works.

Workaround

Thanks for describing the workaround @pgieser. For the convenience of anyone running into this:
The workaround is to add this line in the aws_batch_compute_environment:

lifecycle { ignore_changes = [compute_resources.0.desired_vcpus] }

Confirm that the workaround of @falktan works as of today, terraform plan does not show the changes of desired_vcpu.

I also found that another workaround works as below:
lifecycle { ignore_changes = [ compute_resources[0].desired_vcpus, ] }

terraform --version
Terraform v0.12.24

  • provider.aws v2.54.0
  • provider.template v2.1.2

Hi everyone 👋 The fixes for the resource will support fully optional desired_vcpus have been merged and will release with version 2.68.0 of the Terraform AWS Provider, likely tomorrow. Workarounds such as ignore_changes should no longer be necessary after this release. Thanks to @hectcastro for the investigative and implementation help. 👍

This has been released in version 2.68.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings