Skip to content

Instantly share code, notes, and snippets.

@bushong1
Created February 18, 2019 18:45
Show Gist options
  • Save bushong1/4a34e6f8943345e18186d3a79030fc2f to your computer and use it in GitHub Desktop.
Save bushong1/4a34e6f8943345e18186d3a79030fc2f to your computer and use it in GitHub Desktop.
Script to fetch current Docker version from all AWS ECS instances
#!/usr/bin/env python3
import boto3
import sys
import re
ecs = boto3.client('ecs')
sys.argv.pop(0)
clusters=[]+sys.argv
if len(clusters) == 0:
arn_killer = re.compile(".*/")
print("No arguments given, checking all clusters...")
cluster_arns = ecs.list_clusters()
for cluster_arn in cluster_arns['clusterArns']:
clusters.append(arn_killer.sub("",cluster_arn))
for cluster in clusters:
response = ecs.list_container_instances(cluster=cluster)
response = ecs.describe_container_instances(cluster=cluster,containerInstances=response['containerInstanceArns'])
print(f'Docker versions for cluster: {cluster}')
for instance in response['containerInstances']:
print(f"{instance['ec2InstanceId']}: {instance['versionInfo']['dockerVersion']}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment