Last active
January 20, 2023 13:54
-
-
Save pahud/e37fafddee3dab0a0dfe2e9c64d1b0fc 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