Skip to content

Missing ability to specify manage_draining for external_ec2 capacity provider in ec2.tf #60

@riccardomassullo

Description

@riccardomassullo

Describe the Feature

As specified here Terraform docs for aws_ecs_capacity_provider the managed_draining option is ENABLED by default.

Expected Behavior

We should have a way to specify AT LEAST if should be enabled or not (like with the current managed_termination_protection setting)

Use Case

Being able to disable managed_draining on external ec2 capacity providers

Describe Ideal Solution

It could be achieved by simply adding a field to external_ec2_capacity_providers object:

variable "external_ec2_capacity_providers" {
  description = "External EC2 autoscale groups capacity providers"
  type = map(object({
    autoscaling_group_arn          = string
    managed_termination_protection = bool
    managed_draining               = bool
    managed_scaling_status         = bool
    instance_warmup_period         = optional(number, 300)
    maximum_scaling_step_size      = optional(number, 1)
    minimum_scaling_step_size      = optional(number, 1)
    target_capacity_utilization    = optional(number, 100)
  }))
  default = {}
  validation {
    condition     = !contains(["FARGATE", "FARGATE_SPOT"], keys(var.external_ec2_capacity_providers))
    error_message = "'FARGATE' and 'FARGATE_SPOT' name is reserved"
  }
}

and modifying the external_ec2 resource like this:

resource "aws_ecs_capacity_provider" "external_ec2" {
  for_each = local.external_ec2_capacity_providers
  name     = each.key

  auto_scaling_group_provider {
    auto_scaling_group_arn         = each.value["autoscaling_group_arn"]
    managed_termination_protection = each.value["managed_termination_protection"] ? "ENABLED" : "DISABLED"
    managed_draining               = each.value["managed_draining"] ? "ENABLED" : "DISABLED"

    managed_scaling {
      instance_warmup_period    = each.value["instance_warmup_period"]
      maximum_scaling_step_size = each.value["maximum_scaling_step_size"]
      minimum_scaling_step_size = each.value["minimum_scaling_step_size"]
      status                    = each.value["managed_scaling_status"] ? "ENABLED" : "DISABLED"
      target_capacity           = each.value["target_capacity_utilization"]
    }
  }
}

Alternatives Considered

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions