-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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 #6379
Comments
I'm able to confirm this issue on the latest versions of Terraform CLI and the Terraform AWS Provider. Self-contained Configuration: terraform {
required_providers {
aws = "2.35.0"
}
required_version = "0.12.13"
}
provider "aws" {
region = "us-east-2"
}
data "aws_ami" "test" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn-ami-hvm-*-x86_64-gp2"]
}
}
data "aws_availability_zones" "available" {}
resource "aws_launch_template" "test" {
image_id = data.aws_ami.test.id
instance_type = "t3.micro"
name = "bflad-testing"
}
resource "aws_autoscaling_group" "test" {
availability_zones = data.aws_availability_zones.available.names
desired_capacity = 0
max_size = 0
min_size = 0
name = "bflad-testing"
launch_template {
id = aws_launch_template.test.id
}
}
resource "aws_autoscaling_schedule" "test" {
autoscaling_group_name = aws_autoscaling_group.test.name
scheduled_action_name = "scale-up"
min_size = 15
recurrence = "0 11 * * mon,tue,wed,thu,fri"
} Apply: $ terraform apply
data.aws_availability_zones.available: Refreshing state...
data.aws_ami.test: Refreshing state...
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_autoscaling_group.test will be created
+ resource "aws_autoscaling_group" "test" {
+ arn = (known after apply)
+ availability_zones = [
+ "us-east-2a",
+ "us-east-2b",
+ "us-east-2c",
]
+ default_cooldown = (known after apply)
+ desired_capacity = 0
+ force_delete = false
+ health_check_grace_period = 300
+ health_check_type = (known after apply)
+ id = (known after apply)
+ load_balancers = (known after apply)
+ max_size = 0
+ metrics_granularity = "1Minute"
+ min_size = 0
+ name = "bflad-testing"
+ protect_from_scale_in = false
+ service_linked_role_arn = (known after apply)
+ target_group_arns = (known after apply)
+ vpc_zone_identifier = (known after apply)
+ wait_for_capacity_timeout = "10m"
+ launch_template {
+ id = (known after apply)
+ name = (known after apply)
}
}
# aws_autoscaling_schedule.test will be created
+ resource "aws_autoscaling_schedule" "test" {
+ arn = (known after apply)
+ autoscaling_group_name = "bflad-testing"
+ desired_capacity = (known after apply)
+ end_time = (known after apply)
+ id = (known after apply)
+ max_size = (known after apply)
+ min_size = 15
+ recurrence = "0 11 * * mon,tue,wed,thu,fri"
+ scheduled_action_name = "scale-up"
+ start_time = (known after apply)
}
# aws_launch_template.test will be created
+ resource "aws_launch_template" "test" {
+ arn = (known after apply)
+ default_version = (known after apply)
+ id = (known after apply)
+ image_id = "ami-0c64dd618a49aeee8"
+ instance_type = "t3.micro"
+ latest_version = (known after apply)
+ name = "bflad-testing"
}
Plan: 3 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_launch_template.test: Creating...
aws_launch_template.test: Creation complete after 1s [id=lt-031a10a587afd2718]
aws_autoscaling_group.test: Creating...
aws_autoscaling_group.test: Creation complete after 1s [id=bflad-testing]
aws_autoscaling_schedule.test: Creating...
Error: Error Creating Autoscaling Scheduled Action: ValidationError: Desired capacity must be greater than or equal to min size
status code: 400, request id: 50eeb002-0633-11ea-8d07-9fd23494c204
on main.tf line 42, in resource "aws_autoscaling_schedule" "test":
42: resource "aws_autoscaling_schedule" "test" { The Changing the above resource configuration to the following: resource "aws_autoscaling_schedule" "test" {
autoscaling_group_name = aws_autoscaling_group.test.name
scheduled_action_name = "scale-up"
desired_capacity = -1
max_size = -1
min_size = 15
recurrence = "0 11 * * mon,tue,wed,thu,fri"
} Does apply successfully without a perpetual difference: $ terraform apply
data.aws_ami.test: Refreshing state...
data.aws_availability_zones.available: Refreshing state...
aws_launch_template.test: Refreshing state... [id=lt-031a10a587afd2718]
aws_autoscaling_group.test: Refreshing state... [id=bflad-testing]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_autoscaling_schedule.test will be created
+ resource "aws_autoscaling_schedule" "test" {
+ arn = (known after apply)
+ autoscaling_group_name = "bflad-testing"
+ desired_capacity = -1
+ end_time = (known after apply)
+ id = (known after apply)
+ max_size = -1
+ min_size = 15
+ recurrence = "0 11 * * mon,tue,wed,thu,fri"
+ scheduled_action_name = "scale-up"
+ start_time = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_autoscaling_schedule.test: Creating...
aws_autoscaling_schedule.test: Creation complete after 0s [id=scale-up]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
$ terraform apply
data.aws_availability_zones.available: Refreshing state...
data.aws_ami.test: Refreshing state...
aws_launch_template.test: Refreshing state... [id=lt-031a10a587afd2718]
aws_autoscaling_group.test: Refreshing state... [id=bflad-testing]
aws_autoscaling_schedule.test: Refreshing state... [id=scale-up]
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
$ aws autoscaling describe-scheduled-actions --auto-scaling-group-name bflad-testing --scheduled-action-names scale-up
{
"ScheduledUpdateGroupActions": [
{
"AutoScalingGroupName": "bflad-testing",
"ScheduledActionName": "scale-up",
"ScheduledActionARN": "arn:aws:autoscaling:us-east-2:--OMITTED--:scheduledUpdateGroupAction:675882d8-30a5-4d5a-93a4-cf4102ba0b40:autoScalingGroupName/bflad-testing:scheduledActionName/scale-up",
"Time": "2019-11-14T11:00:00Z",
"StartTime": "2019-11-14T11:00:00Z",
"Recurrence": "0 11 * * mon,tue,wed,thu,fri",
"MinSize": 15
}
]
} Since this odd configuration scenario is documented in the resource documentation and working, we're going to opt to close this issue for now. If in the future the Terraform Plugin SDK does support rich data types that can differentiate between type zero values and an unset configuration (there should be an upstream issue coming here 🔜: https://github.com/hashicorp/terraform-plugin-sdk/issues), I would suggest filing a new feature request after that implementation is complete. |
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! |
This issue was originally opened by @daveadams as hashicorp/terraform#5681. It was migrated here as a result of the provider split. The original body of the issue is below.
Thanks to hashicorp/terraform#4690 we are no longer able to make use of aws_autoscaling_schedule resources. With a config like:
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.
The text was updated successfully, but these errors were encountered: