Open evgenibi opened 4 years ago
Any suggestions for this one?
A workaround is to create it yourself. Here's my example:
resource "aws_autoscaling_policy" "autoscale_policy" {
autoscaling_group_name = aws_autoscaling_group.main_autoscaling_group.name
policy_type = "TargetTrackingScaling"
name = "${aws_autoscaling_group.main_autoscaling_group.name}_auto_scaling_policy"
target_tracking_configuration {
target_value = 100
customized_metric_specification {
metric_name = "CapacityProviderReservation"
namespace = "AWS/ECS/ManagedScaling"
statistic = "Average"
metric_dimension {
name = "CapacityProviderName"
value = aws_ecs_capacity_provider.main_cap_provider.name
}
metric_dimension {
value = aws_ecs_cluster.main_cluster.name
name = "ClusterName"
}
}
disable_scale_in = false
}
}
This does seem to make scaling out work, but scaling in still isn't working for me (possibly due to #12582).
Any love for this one?
also interested in a solution to this, I created the policy but scale-in doesn't work as @peter-boekelheide-ah mentioned. I do see the AmazonECSManaged
tag on the instances so it doesn't appear to be that.
edit: disabling scale-in protection on the instances makes them get terminated, but that isn't compatible with the capacity provider...
i think in some situations it is creating the scaling policy. i was setting up a private module and had added an aws_autoscaling_policy
because one wasn't present on my ASG.
after i was happy with the setup from creating the module i used it again for another one and this time i do have a scaling policy attached to the ASG with a name of AutoScaling-ECSManagedAutoScalingPlan-xxxxx
with a configuration matching the code in in my aws_ecs_capacity_provider
resource. i also got an error creating the aws_autoscaling_policy
resources because the AWS managed ones were already present.
in the module i ended up with the capacity provider depending on the asg so maybe the asg needs to be created before the capacity provider for the managed scaling policy to be created. note that the managed scaling policy does not appear to be tracked in the terraform state.
i've also (unsuccessfully) been trying to get the managed policy re-generated on my original setup - so far turning managed scaling off and back on for the capacity provider hasn't done it, and i'll need to update the running services to try deleting and recreating the capacity provider itself.
edit:
deleting the capacity provider from the cluster and re-adding it via the web ui does create the managed scaling policy in the existing ASG, and updating the capacity provider managed_scaling will update the managed scaling policy (that is not tracked by terraform). trying to re-add the capacity provider via terraform creates it, however it does not 'register' with the cluster or create the scaling policy.
I'm running into this issue. Is there going to be a fix for this?
Community Note
Terraform Version
Terraform v0.12.21
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
When manually creating a capacity provider and linking it to the ASG, a scaling policy is created:
Policy type: Target Tracking scaling Execute policy when: As required to maintain metric CapacityProviderReservation (namespace: AWS/ECS/ManagedScaling, dimensions: CapacityProviderName = test,ClusterName = test, statistic: Average, unit: ) at 100 Take the action: Add or remove instances as required Instances need: 300 seconds to warm up after scaling Disable scale-in: No
Actual Behavior
Scaling policy is empty and is not scaling out because of that when running a task
Steps to Reproduce
auto_scaling_group_provider { auto_scaling_group_arn = aws_autoscaling_group.bender_64_asg.arn managed_termination_protection = "ENABLED"
}
Important Factoids
References
0000