Terraform-provider-aws: Cannot associate the Capacity Provider with ECS cluster which created by aws_batch_compute_environment

Created on 9 Apr 2020  路  2Comments  路  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @ctrongminh as hashicorp/terraform#24615. It was migrated here as a result of the provider split. The original body of the issue is below._


Current Terraform Version

Terraform v0.12.24

Use-cases


Our use case is first create AWS batch compute environment with UNMANAGED type, which will automatically create the ECS cluster. Then, we will create the Launch Template, AutoScaling Group. After that, go to the ECS Cluster, and create the Capacity Provider.
However, I cannot find a way to associate the ECS Cluster created by aws_batch_compute_environment with the resource aws_ecs_capacity_provider.

Attempted Solutions


I try to use the resource aws_ecs_cluster with the ECS cluster name created by aws_batch_compute_environment, and aws_ecs_capacity_provider.resource.name but got error.

There are three cases

  1. Define both capacity_providers and default_capacity_provider_strategy

resource "aws_ecs_cluster" "resource" {
name = "${trimprefix(data.aws_arn.ecs-cluster-resource.resource, "cluster/")}"
capacity_providers = ["${aws_ecs_capacity_provider.resource.name}"]

default_capacity_provider_strategy {
capacity_provider = "${aws_ecs_capacity_provider.resource.name}"
}
}

Got error

Error: InvalidParameterException: Arguments on this idempotent request are inconsistent with arguments used in previous request(s).
  1. Only use the capacity_providers

resource "aws_ecs_cluster" "resource" {
name = "${trimprefix(data.aws_arn.ecs-cluster-resource.resource, "cluster/")}"
capacity_providers = ["${aws_ecs_capacity_provider.resource.name}"]
}
Got the same error

Error: InvalidParameterException: Arguments on this idempotent request are inconsistent with arguments used in previous request(s)
  1. Ony use the default_capacity_provider_strategy

resource "aws_ecs_cluster" "resource" {
name = "${trimprefix(data.aws_arn.ecs-cluster-resource.resource, "cluster/")}"
default_capacity_provider_strategy {
capacity_provider = "${aws_ecs_capacity_provider.resource.name}"
}
}
Got different error

Error: InvalidParameterException: The specified capacity provider strategy cannot contain a capacity provider that is not associated with the cluster. Associate the capacity provider with the cluster or specify a valid capacity provider and try again.

Proposal

References


#11531

new-resource servicecs

All 2 comments

This issue happens on:

  • provider.aws v2.53.0

This happens on v2.70.0 too . can someone help ..?

Was this page helpful?
0 / 5 - 0 ratings