Created
November 30, 2022 08:54
-
-
Save russau/5ba157226bd7fb272768cb1cebc4310e to your computer and use it in GitHub Desktop.
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
# see a list of API versions here: https://github.com/boto/botocore/tree/master/botocore/data | |
import boto3 | |
versions = ["2014-09-01", | |
"2014-10-01", | |
"2015-03-01", | |
"2015-04-15", | |
"2015-10-01", | |
"2016-04-01", | |
"2016-09-15", | |
"2016-11-15"] | |
def paths(obj): | |
all_paths = [] | |
add_paths(all_paths, obj, "") | |
return set(all_paths) | |
def add_paths(all_paths, obj, crumbs): | |
if not isinstance(obj, dict): | |
return | |
for key in obj.keys(): | |
path = crumbs + key | |
all_paths.append(path) | |
add_paths(all_paths, obj[key], path + " > ") | |
prev_paths = None | |
for version in versions: | |
ec2 = boto3.client("ec2", api_version=version) | |
result = ec2.describe_instances() | |
current_paths = paths(result["Reservations"][0]["Instances"][0]) | |
if prev_paths: | |
new_keys = sorted(list(current_paths-prev_paths)) | |
if new_keys: | |
print(f"DescribeInstance version {version}") | |
print("New keys:") | |
for key in new_keys: | |
print(" "+ key) | |
print() | |
prev_paths = current_paths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment