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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

When linking capacity provider to an ASG, a scaling policy is not created #12534

Open
evgenibi opened this issue Mar 26, 2020 · 6 comments
Open
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.

Comments

@evgenibi
Copy link

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.21

Affected Resource(s)

  • aws_autoscaling_group

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

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

  1. Create LC
  2. Create ASG
  3. Create Capacity Provider and link it:

auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.bender_64_asg.arn
managed_termination_protection = "ENABLED"

managed_scaling {
  maximum_scaling_step_size = 10
  minimum_scaling_step_size = 1
  status = "ENABLED"
  target_capacity = 100
}

}

Important Factoids

References

  • #0000
@ghost ghost added the service/autoscaling Issues and PRs that pertain to the autoscaling service. label Mar 26, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 26, 2020
@evgenibi
Copy link
Author

evgenibi commented Apr 6, 2020

Any suggestions for this one?

@peter-boekelheide-ah
Copy link

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).

@evgenibi
Copy link
Author

Any love for this one?

@srolel
Copy link

srolel commented Mar 25, 2021

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...

@hlarsen
Copy link

hlarsen commented Jul 15, 2021

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.

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 8, 2021
@rmccarthy-ellevation
Copy link

I'm running into this issue. Is there going to be a fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/autoscaling Issues and PRs that pertain to the autoscaling service.
Projects
None yet
Development

No branches or pull requests

6 participants