Skip to content

Instantly share code, notes, and snippets.

@feniix
Created January 27, 2015 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feniix/ee79cfb5cdc56ec63f9b to your computer and use it in GitHub Desktop.
Save feniix/ee79cfb5cdc56ec63f9b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
import sys
from pprint import pprint
files = sys.argv[1:]
if not files:
files = ["/dev/stdin"]
for file in files:
f = open(file)
json_data = json.load(f)
ASG = []
for i in json_data['AutoScalingGroups']:
for t in i['Tags']:
if t['Key'] == 'BUILD_ID':
ASG.append(i)
pprint(i)
# OUT: {'AutoScalingGroupARN': 'arn:aws:autoscaling:us-east-1:159116025302:autoScalingGroup:584486eb-73fa-439b-8865-0b6fe5c2d973:autoScalingGroupName/grails-QA-01-26-2015-cf10564b561b65804e6e7cc17b7be391c1da92ce-4',
# OUT: 'AutoScalingGroupName': 'grails-QA-01-26-2015-cf10564b561b65804e6e7cc17b7be391c1da92ce-4',
# OUT: 'AvailabilityZones': ['us-east-1b'],
# OUT: 'CreatedTime': '2015-01-26T16:44:57.913Z',
# OUT: 'DefaultCooldown': 300,
# OUT: 'DesiredCapacity': 0,
# OUT: 'EnabledMetrics': [],
# OUT: 'HealthCheckGracePeriod': 300,
# OUT: 'HealthCheckType': 'ELB',
# OUT: 'Instances': [],
# OUT: 'LaunchConfigurationName': 'grails-QA-01-26-2015-cf10564b561b65804e6e7cc17b7be391c1da92ce-4',
# OUT: 'LoadBalancerNames': ['webapp-internal-qa'],
# OUT: 'MaxSize': 0,
# OUT: 'MinSize': 0,
# OUT: 'SuspendedProcesses': [],
# OUT: 'Tags': [{'Key': 'BUILD_ID',
# OUT: 'PropagateAtLaunch': True,
# OUT: 'ResourceId': 'grails-QA-01-26-2015-cf10564b561b65804e6e7cc17b7be391c1da92ce-4',
# OUT: 'ResourceType': 'auto-scaling-group',
# OUT: 'Value': 'grails-QA-01-26-2015-cf10564b561b65804e6e7cc17b7be391c1da92ce-4'}],
# OUT: 'TerminationPolicies': ['Default'],
# OUT: 'VPCZoneIdentifier': 'subnet-9e8f95b6'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment