It contains lots of files. It looks like a Python-runtime Lambda. That’s a good sign. I think Superwerker still uses the <https://github.com/schubergphilis/awsapilib|awsapilib Python library> to set up some parts of Control Tower.
Oh god The code has to call out to another weird AWS thing to get the list of available Control Tower regions.
def get_available_regions():
"""The regions that control tower can be active in.
Returns:
regions (list): A list of strings of the regions that control tower can be active in.
"""
url = '<https://api.regional-table.region-services.aws.a2z.com/index.json>'
response = requests.get(url, timeout=5)
if not response.ok:
LOGGER.error('Failed to retrieve the info')
return []
return [entry.get('id', '').split(':')[1]
for entry in response.json().get('prices')
if entry.get('id').startswith('controltower')]```
Yeah, you said so. Unfortunately that doesn’t make it more likely that Superwerker or awsapilib don’t suddnenly break one day. These tools are not made by AWS so AWS can change things without warning that break those tools.
You’d thing that the exception I’m seeing would be asserted here if there was an issue with awsapilib
def _validate_regions(self, regions):
available_regions = self.get_available_regions()
if not set(available_regions).issuperset(set(regions)):
raise UnavailableRegion(set(regions) - set(available_regions))
return regions