hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

Consistent change proposal on ecs service capacity provider #11395

Open ghost opened 4 years ago

ghost commented 4 years ago

This issue was originally opened by @vladimirtiukhtin as hashicorp/terraform#23740. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.12.13
+ provider.aws v2.43.0
+ provider.random v2.2.1

Expected Behavior

When cluster's default capacity provider is used, no changes must be proposed to a service with no capacity provider defined.

Actual Behavior

Change is proposed

Steps to Reproduce

Create a cluster with default capacity provider

resource "aws_ecs_cluster" "cluster" {
  name = "test"
  capacity_providers = [
    "FARGATE",
    "FARGATE_SPOT"
  ]

  default_capacity_provider_strategy {
    capacity_provider = "FARGATE_SPOT"
    weight                   = 100
  }
}

Create a service not specifying capacity provider which forces it to use cluster's default

resource "aws_ecs_service" "service" {
  name                              = "test"
  cluster                           = "test"
  task_definition                   = aws_ecs_task_definition.task.arn
  desired_count                     = 1

  network_configuration {
    security_groups  = var.security_group_id
    subnets          = var.subnets
    assign_public_ip = false
  }
}

Apply. Now plan. A change to capacity provider will be proposed

louis-ellevation commented 4 years ago

I am currently having trouble due to this issue. Combined with this issue it seems I can't have an ECS service use the default capacity provider without said service incurring downtime every time the terraform config is applied.

alex-bes commented 4 years ago

I have managed to work around this issue as described in https://github.com/terraform-providers/terraform-provider-aws/issues/11351#issuecomment-656344519