Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS ECS cluster Capacity Provider

I'm using this cloudformation template to create capacity providers for ECS cluster with the autoscaling group specified in the ecs capacity provider:

"ECSCapacityProvider": {
  "Type": "AWS::ECS::CapacityProvider",
  "Properties": {
    "AutoScalingGroupProvider": {
      "AutoScalingGroupArn": {
        "Ref": "AutoScalingGroup"
      }
    }
  },
  "DependsOn": "AutoScalingGroup"
},
"DRCluster": {
  "Type": "AWS::ECS::Cluster",
  "Properties": {
    "ClusterName": {
      "Ref": "WindowsECSCluster"
    },
    "CapacityProviders": "ECSCapacityProvider",
    "Tags": [
      {
        "Key": "environment",
        "Value": "dr"
      }
    ]
  },
  "DependsOn": "ECSCapacityProvider"
}

But while creating the stack it resulted in the following error:

Model validation failed (#/CapacityProviders: expected type: JSONArray, found: String)

I could not find proper documentation for the capacity providers. I'm using it to attach the Auto Scaling group to the cluster, which i hope is the correct way to do so. I'm new to cloudformation, any help is much appreciated.

like image 549
Aditya Nair Avatar asked Sep 12 '25 04:09

Aditya Nair


1 Answers

CapacityProviders is a List of String, not a String like you have now:

"CapacityProviders" : "ECSCapacityProvider",

Therefore, in you DRCluster you can use the following instead:

"CapacityProviders" : [ {"Ref": "ECSCapacityProvider"} ],
like image 117
Marcin Avatar answered Sep 14 '25 21:09

Marcin