Skip to content

Instantly share code, notes, and snippets.

@kisst
Created March 24, 2021 11:07
Show Gist options
  • Save kisst/a542079528184546b40e039b4b7c09dd to your computer and use it in GitHub Desktop.
Save kisst/a542079528184546b40e039b4b7c09dd to your computer and use it in GitHub Desktop.
Recover the old view in the regional supported service table
#!/usr/bin/env python3
"""
The missing function for AWS region support
"""
from collections import defaultdict
import requests
import pandas as pd
list_of_regions = []
list_of_services = []
support_matrix = defaultdict(dict)
def supported(json, service, region):
"""
Check in the whole map if it's suppoted or not
"""
for item in json:
if (
item["attributes"]["aws:region"] == region
and item["attributes"]["aws:serviceName"] == service
):
return True
return False
r = requests.get("https://api.regional-table.region-services.aws.a2z.com/index.json")
for entry in r.json()["prices"]:#!/usr/bin/env python3
"""
The missing function for AWS region support
"""
from collections import defaultdict
import requests
import pandas as pd
list_of_regions = []
list_of_services = []
support_matrix = defaultdict(dict)
def supported(json, service, region):
"""
Check in the whole map if it's suppoted or not
"""
for item in json:
if (
item["attributes"]["aws:region"] == region
and item["attributes"]["aws:serviceName"] == service
):
return True
return False
r = requests.get("https://api.regional-table.region-services.aws.a2z.com/index.json")
for entry in r.json()["prices"]:
if entry["attributes"]["aws:region"] not in list_of_regions:
list_of_regions.append(entry["attributes"]["aws:region"])
if entry["attributes"]["aws:serviceName"] not in list_of_services:
list_of_services.append(entry["attributes"]["aws:serviceName"])
for region in list_of_regions:
for service in list_of_services:
if supported(r.json()["prices"], service, region):
support_matrix[service][region] = "✓"
else:
support_matrix[service][region] = "✗"
pd.set_option("display.expand_frame_repr", False)
pd.set_option("display.max_rows", 500)
pd.set_option("display.max_columns", 500)
pd.set_option("display.width", 1000)
df = pd.DataFrame(support_matrix).T
print(df)
if entry["attributes"]["aws:region"] not in list_of_regions:
list_of_regions.append(entry["attributes"]["aws:region"])
if entry["attributes"]["aws:serviceName"] not in list_of_services:
list_of_services.append(entry["attributes"]["aws:serviceName"])
for region in list_of_regions:
for service in list_of_services:
if supported(r.json()["prices"], service, region):
support_matrix[service][region] = "✓"
else:
support_matrix[service][region] = "✗"
pd.set_option("display.expand_frame_repr", False)
pd.set_option("display.max_rows", 500)
pd.set_option("display.max_columns", 500)
pd.set_option("display.width", 1000)
df = pd.DataFrame(support_matrix).T
print(df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment