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

aws_autoscaling_schedule defaults desired_capacity to zero with no way of specifying an empty value #5681

Closed
daveadams opened this issue Mar 17, 2016 · 17 comments

Comments

@daveadams
Copy link
Contributor

Thanks to #4690 we are no longer able to make use of aws_autoscaling_schedule resources. With a config like:

resource "aws_autoscaling_schedule" "asg-scale-up" {
  autoscaling_group_name = "my-asg"
  scheduled_action_name  = "scale-up"
  min_size               = 15
  recurrence             = "0 11 * * mon,tue,wed,thu,fri"
}

We get an error (via Terraform, from the AWS API) that "desired_capacity cannot be less than min_size". But we wish for desired_capacity to be managed by the autoscaling group, not by Terraform, and so we cannot specify a desired capacity. There should be a way to indicate that we do not wish for anything to be specified for desired_capacity.

@catsby
Copy link
Contributor

catsby commented Mar 17, 2016

Hey @daveadams – thanks for opening this. I also opened #5694 to push this along, as we're in a bit of a tough spot here, needing to both omit and allow zero values.

@daveadams
Copy link
Contributor Author

Great. Yeah I figured it had something to do with that.

@ghost
Copy link

ghost commented Jun 4, 2016

Can you make -1 equivalent to omit behind the scenes? This could be useful for making other generic modules where I want to reuse the module but not every key. Even better would be to allow a null or nil or some other non-magic number token for specific resource keys that allow it.

@urjitbhatia
Copy link

@daveadams similar to what ^ said, I'd like to apply changes to the infra without resetting desired capacity to a fixed number (because we autoscale outside terraform). Omitting the value sets it to the min right now (I think?). Is there a way to apply changes without changing the current value for desired capacity?

@joeig
Copy link

joeig commented Oct 24, 2016

Same thing here: We just want to change min value by schedule, but the desired (and max) value should be kept. Terraform raises: "Error Creating Autoscaling Scheduled Action: ValidationError: Desired capacity must be less than or equal to max size"

glasser added a commit to meteor/terraform that referenced this issue Nov 8, 2016
Specifically, this allows you to create a schedule which only changes
some of the group parameters without changing others, by setting the
parameters you wish to remain empty to -1.  This means you can adjust
min or max size without affecting the desired capacity, for example.

The ad hoc support for -1 isn't as nice as having real support for
leaving values out (see hashicorp#5694) but it solves a real use case.

Fixes hashicorp#5681.
glasser added a commit to meteor/terraform that referenced this issue Nov 8, 2016
Specifically, this allows you to create a schedule which only changes
some of the group parameters without changing others, by setting the
parameters you wish to remain empty to -1.  This means you can adjust
min or max size without affecting the desired capacity, for example.

The ad hoc support for -1 isn't as nice as having real support for
leaving values out (see hashicorp#5694) but it solves a real use case.

Fixes hashicorp#5681.
@glasser
Copy link
Contributor

glasser commented Nov 8, 2016

Here's a PR to fix it using the ghost's suggestion. #9941

glasser added a commit to meteor/terraform that referenced this issue Dec 28, 2016
Specifically, this allows you to create a schedule which only changes
some of the group parameters without changing others, by setting the
parameters you wish to remain empty to -1.  This means you can adjust
min or max size without affecting the desired capacity, for example.

The ad hoc support for -1 isn't as nice as having real support for
leaving values out (see hashicorp#5694) but it solves a real use case.

Fixes hashicorp#5681.
@analytically
Copy link

Setting desired, min and max all to "1" fails with

aws_autoscaling_schedule.add_workers_before_working_time: Error Creating Autoscaling Scheduled Action: ValidationError: Desired capacity must be less than or equal to max size

@cyrilgdn
Copy link

cyrilgdn commented Mar 3, 2017

Any update? I've just created scheduled action and have to specify min_size and max_size while I just want to change desired_capicity :-(

@glasser
Copy link
Contributor

glasser commented May 12, 2017

#9941 still works for us. I'd love to see it merged!

@mcwqy9
Copy link

mcwqy9 commented May 15, 2017

This is an active blocker for us. Would love to see #9941 get reviewed/merged.

@nikhilmat
Copy link

This is also a blocker for us, another bump to #9941 :)

glasser added a commit to meteor/terraform that referenced this issue Jun 29, 2017
Specifically, this allows you to create a schedule which only changes
some of the group parameters without changing others, by setting the
parameters you wish to remain empty to -1.  This means you can adjust
min or max size without affecting the desired capacity, for example.

The ad hoc support for -1 isn't as nice as having real support for
leaving values out (see hashicorp#5694) but it solves a real use case.

Fixes hashicorp#5681.
@JesperTerkelsen
Copy link

👍

@boboli
Copy link

boboli commented Jan 8, 2018

Just found this in the docs for those who found this issue:

min_size - (Optional) The minimum size for the Auto Scaling group. Default
Set to -1 if you don't want to change the minimum size at the scheduled time.
max_size - (Optional) The maximum size for the Auto Scaling group. Default
Set to -1 if you don't want to change the maximum size at the scheduled time.
desired_capacity - (Optional) The number of EC2 instances that should be running in the group. > Default 0. Set to -1 if you don't want to change the desired capacity at the scheduled time.

Seems like the desired behavior can be triggered by manually setting them to -1.

@catsby: Is there a reason why the default is 0 and not -1? I would normally expect that not setting optional values means to not change them at the scheduled time rather than setting them to 0.
And what are the actual defaults for min and max? The docs read like they're incomplete.

@glasser
Copy link
Contributor

glasser commented Jan 8, 2018

I implemented the PR that got merged (though somebody else ported it to a new repo). My memory was, at least at that time, Terraform couldn't usefully differentiate between "parameter given as 0" and "parameter left blank".

@daveadams
Copy link
Contributor Author

That is a side-effect of the Go serialization I think, but there are ways to check for empty vs literal zero, and other AWS provider resources handle this sort of situation just fine, also this used to work, long ago...

@ghost
Copy link

ghost commented Nov 7, 2018

This issue has been automatically migrated to hashicorp/terraform-provider-aws#6379 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-aws#6379.

@ghost
Copy link

ghost commented Mar 31, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.