Created
February 18, 2019 18:45
-
-
Save bushong1/4a34e6f8943345e18186d3a79030fc2f to your computer and use it in GitHub Desktop.
Script to fetch current Docker version from all AWS ECS instances
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
#!/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