From 575b6347f949af97a1639953b2add49ef033e211 Mon Sep 17 00:00:00 2001 From: Ben Fortuna Date: Fri, 25 Mar 2022 16:48:25 +1100 Subject: [PATCH] Updated capacity provider config (fixes issue with destroy) --- .env | 2 +- main.tf | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.env b/.env index bf5e28f..e29d5d1 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -TERRAFORM_VERSION=1.1.0 +TERRAFORM_VERSION=1.1.7 AWS_DEFAULT_REGION?=ap-southeast-2 ifneq (, $(shell which docker)) diff --git a/main.tf b/main.tf index 9cfc5e8..27fbbe5 100644 --- a/main.tf +++ b/main.tf @@ -6,16 +6,7 @@ * ![AWS ECS Cluster](aws_ecs_cluster.png) */ resource "aws_ecs_cluster" "cluster" { - name = var.name - capacity_providers = var.capacity_providers - - dynamic "default_capacity_provider_strategy" { - for_each = var.default_capacity_provider != null ? [1] : [] - content { - capacity_provider = var.default_capacity_provider - weight = 100 - } - } + name = var.name #checkov:skip=CKV_AWS_65:Dynamic container insights setting { @@ -32,3 +23,16 @@ resource "aws_ecs_cluster" "cluster" { }, ) } + +resource "aws_ecs_cluster_capacity_providers" "capacity_providers" { + cluster_name = aws_ecs_cluster.cluster.name + capacity_providers = var.capacity_providers + + dynamic "default_capacity_provider_strategy" { + for_each = var.default_capacity_provider != null ? [1] : [] + content { + capacity_provider = var.default_capacity_provider + weight = 100 + } + } +}