{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/4690","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/4690/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/4690/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/4690/events","html_url":"https://github.com/hashicorp/terraform/issues/4690","id":126907921,"number":4690,"title":"aws_autoscaling_schedule - cannot set zero to max/min/desired","user":{"login":"AirbornePorcine","id":7409186,"avatar_url":"https://avatars.githubusercontent.com/u/7409186?v=3","gravatar_id":"","url":"https://api.github.com/users/AirbornePorcine","html_url":"https://github.com/AirbornePorcine","followers_url":"https://api.github.com/users/AirbornePorcine/followers","following_url":"https://api.github.com/users/AirbornePorcine/following{/other_user}","gists_url":"https://api.github.com/users/AirbornePorcine/gists{/gist_id}","starred_url":"https://api.github.com/users/AirbornePorcine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirbornePorcine/subscriptions","organizations_url":"https://api.github.com/users/AirbornePorcine/orgs","repos_url":"https://api.github.com/users/AirbornePorcine/repos","events_url":"https://api.github.com/users/AirbornePorcine/events{/privacy}","received_events_url":"https://api.github.com/users/AirbornePorcine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-15T16:35:33Z","updated_at":"2016-01-15T16:36:31Z","closed_at":null,"body":"Hi!\r\n\r\nSo I'm attempting to create a aws_autoscaling_schedule resource that shuts down all my instances overnight. When I try to do this with terraform however, any field of max_size/min_size/desired_capacity that is set to zero is effectively ignored. If they're all set to zero, you get this error: \r\n\r\n```\r\nError Creating Autoscaling Scheduled Action: ValidationError: At least one of max size, min size, or desired capacity must be specified\r\n\tstatus code: 400, request id: 02af3c57-bba3-11e5-a6c3-99fcfc3310db\r\n```\r\n\r\nIf I set any single field to a non-zero value, then my autoscaling schedule (via aws autoscaling describe-scheduled-action) looks like this (min/desired set to zero, max set to 2):\r\n\r\n```\r\n{\r\n    \"ScheduledUpdateGroupActions\": [\r\n        {\r\n            \"AutoScalingGroupName\": \"xxx\",\r\n            \"MaxSize\": 2,\r\n            \"ScheduledActionARN\": \"xxx\",\r\n            \"ScheduledActionName\": \"ShutdownAfterBusinessHours\",\r\n            \"StartTime\": \"2016-01-15T16:20:00Z\",\r\n            \"Time\": \"2016-01-15T16:20:00Z\",\r\n            \"EndTime\": \"2016-01-15T16:30:00Z\"\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nLooking at the code in resource_aws_autoscheduling_schedule.go, I noticed the following:\r\n\r\n```\r\n\tif attr, ok := d.GetOk(\"min_size\"); ok {\r\n\t\tparams.MinSize = aws.Int64(int64(attr.(int)))\r\n\t}\r\n\r\n\tif attr, ok := d.GetOk(\"max_size\"); ok {\r\n\t\tparams.MaxSize = aws.Int64(int64(attr.(int)))\r\n\t}\r\n\r\n\tif attr, ok := d.GetOk(\"desired_capacity\"); ok {\r\n\t\tparams.DesiredCapacity = aws.Int64(int64(attr.(int)))\r\n\t}\r\n```\r\n\r\nThe d.GetOk call is specifically meant to not return zero values. Changing this to just Ok wouldn't work very well since then (as I understand it), not specifying a field would be equivalent to a zero value.\r\n\r\nSo, looking for a little guidance on how you'd like to resolve this, then I can submit a PR. Thanks!"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/172009204","html_url":"https://github.com/hashicorp/terraform/issues/4690#issuecomment-172009204","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/4690","id":172009204,"user":{"login":"AirbornePorcine","id":7409186,"avatar_url":"https://avatars.githubusercontent.com/u/7409186?v=3","gravatar_id":"","url":"https://api.github.com/users/AirbornePorcine","html_url":"https://github.com/AirbornePorcine","followers_url":"https://api.github.com/users/AirbornePorcine/followers","following_url":"https://api.github.com/users/AirbornePorcine/following{/other_user}","gists_url":"https://api.github.com/users/AirbornePorcine/gists{/gist_id}","starred_url":"https://api.github.com/users/AirbornePorcine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AirbornePorcine/subscriptions","organizations_url":"https://api.github.com/users/AirbornePorcine/orgs","repos_url":"https://api.github.com/users/AirbornePorcine/repos","events_url":"https://api.github.com/users/AirbornePorcine/events{/privacy}","received_events_url":"https://api.github.com/users/AirbornePorcine/received_events","type":"User","site_admin":false},"created_at":"2016-01-15T16:36:31Z","updated_at":"2016-01-15T16:36:31Z","body":"Oh, I should note - I did attempt to use zero values through the AWS CLI manually, and it does fully accept a scheduled scaling action that sets min/desired to zero, which is the effect we're looking for."}}