Created
February 9, 2017 17:55
-
-
Save alvarow/6c6ffa4fd6ddf59987ffe7c816ca05f0 to your computer and use it in GitHub Desktop.
My AWS CLI ECS cheat sheet
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
# Get number of running containers of a service | |
aws --profile saml --output json ecs describe-services --cluster DIT-DMZ --service adp-e-bot-kafka | jq '.services[]|.desiredCount' | |
# Get a list of all task definitions | |
aws --profile saml --output text ecs list-task-definition-families | |
# Get the JSONs of a task definition | |
aws --profile saml --output json ecs describe-task-definition --task-def DIT-adp-e-bot | jq '.taskDefinition|if .networkMode then {family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, networkMode: .networkMode} else {family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions} end' | |
# Get all task definition and save each as a JSON | |
while read a b; do aws --profile saml --output json ecs describe-task-definition --task-def $b | jq '.taskDefinition|if .networkMode then {family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions, networkMode: .networkMode} else {family: .family, volumes: .volumes, containerDefinitions: .containerDefinitions} end' > $b.json ; done < <(aws --profile saml --output text ecs list-task-definition-families) | |
# Delete all images without a tag from a given repo | |
aws ecr batch-delete-image --repository-name myrepo --image-ids $(aws ecr list-images --repository-name myrepo --filter tagStatus=UNTAGGED --query 'imageIds[*]'| tr -d " \t\n\r") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment