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

ECS Target Tracking AutoScaling #3112

Closed
danieladams456 opened this issue Jan 23, 2018 · 4 comments · Fixed by #3122
Closed

ECS Target Tracking AutoScaling #3112

danieladams456 opened this issue Jan 23, 2018 · 4 comments · Fixed by #3122
Labels
bug Addresses a defect in current functionality.
Milestone

Comments

@danieladams456
Copy link
Contributor

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"
        }
    ]
}
@bflad
Copy link
Contributor

bflad commented Jan 24, 2018

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

@bflad
Copy link
Contributor

bflad commented Jan 26, 2018

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.

@bflad bflad added this to the v1.8.0 milestone Jan 29, 2018
@bflad
Copy link
Contributor

bflad commented Jan 29, 2018

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.

@ghost
Copy link

ghost commented Apr 8, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
2 participants