Forked from pahud/update-ecs-cluster-capacity-providers.sh
Created
April 17, 2020 09:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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