Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvn-bachhuynh-dn/e496f55eff05eddf191227197e5f3e11 to your computer and use it in GitHub Desktop.
Save mvn-bachhuynh-dn/e496f55eff05eddf191227197e5f3e11 to your computer and use it in GitHub Desktop.
Update the capacity providers of your existing ECS clusters for Fargate
# 1. update your aws cli
# https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
#
# 2. update your existing cluster with capacity providers support
CLUSTER_NAME=fargate
SERVICE_NAME=myservice
FARGATE_WEIGHT=1
FARGATE_SPOT_WEIGHT=1
FARGATE_BASE=1
FARGATE_SPOT_BASE=0
# update the existing cluster
aws ecs put-cluster-capacity-providers --cluster ${CLUSTER_NAME} \
--capacity-providers FARGATE FARGATE_SPOT \
--default-capacity-provider-strategy capacityProvider=FARGATE_SPOT,weight=1
# update existing service
aws ecs update-service --cluster fargate --service ${SERVICE_NAME} \
--capacity-provider-strategy capacityProvider=FARGATE_SPOT,weight=${FARGATE_SPOT_WEIGHT},base=${FARGATE_SPOT_BASE} \
capacityProvider=FARGATE,weight=${FARGATE_WEIGHT},base=${FARGATE_BASE} --force-new-deployment
# describe the service to see its capacityProviderStrategy
aws ecs describe-services --cluster ${CLUSTER_NAME} --service ${SERVICE_NAME} --query 'services[0].capacityProviderStrategy'  
[
{
"capacityProvider": "FARGATE_SPOT",
"weight": 1,
"base": 0
},
{
"capacityProvider": "FARGATE",
"weight": 1,
"base": 1
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment