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

[Enhancement]: aws_appautoscaling_policy step_adjustment.metric_interval_(lower|upper)_bound type change to float #29413

Open
watarukura opened this issue Feb 15, 2023 · 1 comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/appautoscaling Issues and PRs that pertain to the appautoscaling service.

Comments

@watarukura
Copy link
Contributor

Description

// Loop over our configured step adjustments and create an array
// of aws-sdk-go compatible objects. We're forced to convert strings
// to floats here because there's no way to detect whether or not
// an uninitialized, optional schema element is "0.0" deliberately.
// With strings, we can test for "", which is definitely an empty
// struct value.
for _, raw := range configured {
data := raw.(map[string]interface{})
a := &autoscaling.StepAdjustment{
ScalingAdjustment: aws.Int64(int64(data["scaling_adjustment"].(int))),
}
if data["metric_interval_lower_bound"] != "" {
bound := data["metric_interval_lower_bound"]
switch bound := bound.(type) {
case string:
f, err := strconv.ParseFloat(bound, 64)
if err != nil {
return nil, fmt.Errorf(
"metric_interval_lower_bound must be a float value represented as a string")
}
a.MetricIntervalLowerBound = aws.Float64(f)
default:
return nil, fmt.Errorf(
"metric_interval_lower_bound isn't a string. This is a bug. Please file an issue.")
}
}

Now, step_adjustment.metric_interval_(lower|upper)_bound set schema.TypeString.
I apply this, and error occured.

resource "aws_appautoscaling_policy" "madras_queue_worker_scale_up" {
  ...
  policy_type        = "StepScaling"

  step_scaling_policy_configuration {
    adjustment_type         = "ExactCapacity"
    metric_aggregation_type = "Average"

    step_adjustment {
      metric_interval_lower_bound = 0
      metric_interval_upper_bound = 50
      scaling_adjustment          = 10
    }
    step_adjustment {
      metric_interval_lower_bound = 50
      metric_interval_upper_bound = 100
      scaling_adjustment          = 20
    }
    step_adjustment {
      metric_interval_lower_bound = 100
      metric_interval_upper_bound = 150
      scaling_adjustment          = 30
    }
    step_adjustment {
      metric_interval_lower_bound = 150
      metric_interval_upper_bound = 200
      scaling_adjustment          = 40
    }
    step_adjustment {
      metric_interval_lower_bound = 250
      scaling_adjustment          = 50
    }
  }
}

Error message is here.
Error: creating Application Auto Scaling Policy (scale_up): ValidationException: Step adjustment intervals cannot have gaps between them

Affected Resource(s) and/or Data Source(s)

  • aws_appautoscaling_policy

Potential Terraform Configuration

No response

References

This is NG pattern terraform plan result.
sort by metric_interval_lower_bound as string, and apply error occured.

  + resource "aws_appautoscaling_policy" "scale_up" {
      + alarm_arns         = (known after apply)
      + arn                = (known after apply)
      + id                 = (known after apply)
      + name               = "scale-up"
      + policy_type        = "StepScaling"
      + resource_id        = "service/foo/bar"
      + scalable_dimension = "ecs:service:DesiredCount"
      + service_namespace  = "ecs"

      + step_scaling_policy_configuration {
          + adjustment_type         = "ExactCapacity"
          + metric_aggregation_type = "Average"

          + step_adjustment {
              + metric_interval_lower_bound = "0"
              + metric_interval_upper_bound = "50"
              + scaling_adjustment          = 10
            }
          + step_adjustment {
              + metric_interval_lower_bound = "100"
              + metric_interval_upper_bound = "150"
              + scaling_adjustment          = 30
            }
          + step_adjustment {
              + metric_interval_lower_bound = "150"
              + metric_interval_upper_bound = "200"
              + scaling_adjustment          = 40
            }
          + step_adjustment {
              + metric_interval_lower_bound = "250"
              + scaling_adjustment          = 50
            }
          + step_adjustment {
              + metric_interval_lower_bound = "50"
              + metric_interval_upper_bound = "100"
              + scaling_adjustment          = 20
            }
        }
    }

This is OK pattern.

  + resource "aws_appautoscaling_policy" "scale_up" {
      + alarm_arns         = (known after apply)
      + arn                = (known after apply)
      + id                 = (known after apply)
      + name               = "scale-up"
      + policy_type        = "StepScaling"
      + resource_id        = "service/foo/bar"
      + scalable_dimension = "ecs:service:DesiredCount"
      + service_namespace  = "ecs"

      + step_scaling_policy_configuration {
          + adjustment_type         = "ExactCapacity"
          + metric_aggregation_type = "Average"

          + step_adjustment {
              + metric_interval_lower_bound = "0"
              + metric_interval_upper_bound = "100"
              + scaling_adjustment          = 1
            }
          + step_adjustment {
              + metric_interval_lower_bound = "100"
              + metric_interval_upper_bound = "200"
              + scaling_adjustment          = 4
            }
          + step_adjustment {
              + metric_interval_lower_bound = "200"
              + metric_interval_upper_bound = "300"
              + scaling_adjustment          = 6
            }
          + step_adjustment {
              + metric_interval_lower_bound = "300"
              + metric_interval_upper_bound = "400"
              + scaling_adjustment          = 8
            }
          + step_adjustment {
              + metric_interval_lower_bound = "400"
              + scaling_adjustment          = 10
            }
        }

Would you like to implement a fix?

None

@watarukura watarukura added enhancement Requests to existing resources that expand the functionality or scope. needs-triage Waiting for first response or review from a maintainer. labels Feb 15, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/appautoscaling Issues and PRs that pertain to the appautoscaling service. label Feb 15, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/appautoscaling Issues and PRs that pertain to the appautoscaling service.
Projects
None yet
Development

No branches or pull requests

2 participants