Terraform-provider-aws: ECS Target Tracking AutoScaling

Created on 23 Jan 2018  ยท  4Comments  ยท  Source: hashicorp/terraform-provider-aws

Terraform Version

Terraform v0.11.2
+ provider.aws v1.7.1
+ provider.template v1.0.0

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_appautoscaling_policy

Terraform Configuration Files

resource "aws_appautoscaling_target" "ecs_target" {
  max_capacity       = 5
  min_capacity       = 2
  resource_id        = "service/ecs-cluster/ecs-service"
  scalable_dimension = "ecs:service:DesiredCount"
  service_namespace  = "ecs"
}

resource "aws_appautoscaling_policy" "ecs_targettracking" {
  name               = "ECSServiceAverageCPUUtilization:${aws_appautoscaling_target.ecs_target.resource_id}"
  policy_type        = "TargetTrackingScaling"
  resource_id        = "${aws_appautoscaling_target.ecs_target.resource_id}"
  scalable_dimension = "${aws_appautoscaling_target.ecs_target.scalable_dimension}"
  service_namespace  = "${aws_appautoscaling_target.ecs_target.service_namespace}"

  target_tracking_scaling_policy_configuration {
    predefined_metric_specification {
      predefined_metric_type = "ECSServiceAverageCPUUtilization"
    }

    target_value = 50
  }
}

Expected Behavior

Create a target tracking scaling policy for the ECS service

Actual Behavior

Validation error: Error: aws_appautoscaling_policy.ecs_targettracking: "target_tracking_scaling_policy_configuration.0.predefined_metric_specification.0.predefined_metric_type" contains an invalid metric "ECSServiceAverageCPUUtilization". Valid metric are ["DynamoDBReadCapacityUtilization" "DynamoDBWriteCapacityUtilization"].

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

API/CLI Reference

https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html

Command

aws application-autoscaling put-scaling-policy --cli-input-json file://scale-cli.json

Payload
{
  "PolicyName": "ECSServiceAverageCPUUtilization:service/ecs-cluster/ecs-service",
  "ServiceNamespace": "ecs",
  "ResourceId": "service/ecs-cluster/ecs-service",
  "ScalableDimension": "ecs:service:DesiredCount",
  "PolicyType": "TargetTrackingScaling",
  "TargetTrackingScalingPolicyConfiguration": {
    "PredefinedMetricSpecification": {
      "PredefinedMetricType": "ECSServiceAverageCPUUtilization"
    },
    "TargetValue": 50
  }
}

Response

{
    "PolicyARN": "arn:aws:autoscaling:us-east-1:821452665997:scalingPolicy:a0d9cc4b-0f5e-4a4a-88bb-1b549bea1ebb:resource/ecs/service/ecs-cluster/ecs-service:policyName/ECSServiceAverageCPUUtilization:service/ecs-cluster/ecs-service",
    "Alarms": [
        {
            "AlarmName": "TargetTracking-service/ecs-cluster/ecs-service-AlarmHigh-adaa1f5f-bb37-4da6-ae26-0b7829fdb747",
            "AlarmARN": "arn:aws:cloudwatch:us-east-1:821452665997:alarm:TargetTracking-service/ecs-cluster/ecs-service-AlarmHigh-adaa1f5f-bb37-4da6-ae26-0b7829fdb747"
        },
        {
            "AlarmName": "TargetTracking-service/ecs-cluster/ecs-service-AlarmLow-88535a41-70d2-4cf6-9a21-37aaa24ba103",
            "AlarmARN": "arn:aws:cloudwatch:us-east-1:821452665997:alarm:TargetTracking-service/ecs-cluster/ecs-service-AlarmLow-88535a41-70d2-4cf6-9a21-37aaa24ba103"
        }
    ]
}
bug servicapplicationautoscaling

Most helpful comment

The validation has been updated to support all the latest supported metrics types in master and this will release in v1.8.0, likely today. We're discussing the possibility of removing this validation in the future to prevent the disconnect between specific Terraform versions and updates to AWS services.

All 4 comments

Submitted PR #3122 to allow all the latest metrics types.

The validation has been updated to support all the latest supported metrics types in master and this will release in v1.8.0, likely today. We're discussing the possibility of removing this validation in the future to prevent the disconnect between specific Terraform versions and updates to AWS services.

This has been released in terraform-provider-aws version 1.8.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

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!

Was this page helpful?
0 / 5 - 0 ratings