hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.73k stars 9.09k forks source link

Misleading error message in aws_appautoscaling_scheduled_action for missing "?" in cron expression #13995

Open sagischwarz opened 4 years ago

sagischwarz commented 4 years ago

Terraform Version

Affected Resource(s)

Terraform Configuration Files

resource "aws_appautoscaling_target" "autoscaling_target" {
  max_capacity       = 2
  min_capacity       = 1
  resource_id        = "service/${var.ecs_cluster_name}/${var.name}"
  scalable_dimension = "ecs:service:DesiredCount"
  service_namespace  = "ecs"
}

resource "aws_appautoscaling_scheduled_action" "scale_down_for_night" {
  name               = "${var.name}_scale_down_for_night"
  service_namespace  = aws_appautoscaling_target.autoscaling_target.service_namespace
  resource_id        = aws_appautoscaling_target.autoscaling_target.resource_id
  scalable_dimension = aws_appautoscaling_target.autoscaling_target.scalable_dimension
  schedule           = "cron(0 16 * * MON-FRI *)"

  scalable_target_action {
    min_capacity = 1
    max_capacity = 1
  }
}

Debug Output

Error: Error putting scheduled action: ValidationException: Invalid schedule expression. Details: Invalid CRON expression: error at position 0, details: Invalid Month value: 'MON'
  on .terraform/modules/XXX/microservice/main.tf line 471, in resource "aws_appautoscaling_scheduled_action" "scale_down_for_night":
 471: resource "aws_appautoscaling_scheduled_action" "scale_down_for_night" {

Expected Behavior

Terraform should tell me that the value for Day-of-month in the cron expression must be a ? if the value of Day-of-week is set as in my example, which is explained in the AWS documentation (correct expression is cron(0 16 ? * MON-FRI *)).

Actual Behavior

The Terraform error indicates that MON ist an invalid value for Month, which is misleading.

Steps to Reproduce

Try to create a aws_appautoscaling_scheduled_action with a cron expression as shown in the example above.

igorjanevski commented 9 months ago

BUMP

This is still an issue

derek-cbtw commented 3 months ago

Bump, still an issue

ashafaei commented 2 weeks ago

still an issue.