Skip to content

[Enhancement]: Support aws_appautoscaling_policy ScalingTargetId alternative to resource_id etc #35021

@sparr

Description

@sparr

Description

aws_appautoscaling_policy has required parameters resource_id, scalable_dimension, and service_namespace. When using an aws_appautoscaling_target, all of those parameters will be copied from the target, e.g.

  resource_id        = aws_appautoscaling_target.test.resource_id
  scalable_dimension = aws_appautoscaling_target.test.scalable_dimension
  service_namespace  = aws_appautoscaling_target.test.service_namespace

CFN simplifies this by providing a ScalingTargetId property for the auto scaling policy, which replaces all three of the other parameters. I think this shorthand would improve the readability of equivalent HCL.

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

aws_appautoscaling_policy
aws_appautoscaling_target

Potential Terraform Configuration

resource "aws_appautoscaling_policy" "test" {
  name = "foo"
  policy_type = "TargetTrackingScaling"

  # # old
  # resource_id        = aws_appautoscaling_target.test.resource_id
  # scalable_dimension = aws_appautoscaling_target.test.scalable_dimension
  # service_namespace  = aws_appautoscaling_target.test.service_namespace

  # new
  scaling_target_id = aws_appautoscaling_target.test.id

  target_tracking_scaling_policy_configuration {
    predefined_metric_specification {
      predefined_metric_type = "ECSServiceAverageCPUUtilitzation"
    }
    target_value = 50 #% cpu utilization
    scale_in_cooldown = 10
    scale_out_cooldown = 10
  }
}

References

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalingpolicy.html#cfn-applicationautoscaling-scalingpolicy-scalingtargetid

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequests to existing resources that expand the functionality or scope.service/appautoscalingIssues and PRs that pertain to the appautoscaling service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions