@@ -80,43 +80,40 @@ def retrieve_aws_regions(self) -> dict[str, dict[str, Any]]:
80
80
# Then we get the list of all regions from the AWS regions page
81
81
# To get the location of the regions (Based on location name)
82
82
amazon_region_page = requests .get (AMAZON_REGION_URL , timeout = 5 )
83
-
84
83
amazon_region_page_soup = BeautifulSoup (amazon_region_page .content , "html.parser" )
85
84
86
85
regions = {}
87
-
88
86
tables = amazon_region_page_soup .find_all ("table" )
89
87
90
88
if len (tables ) == 0 :
91
89
raise ValueError ("Could not find any tables on the AWS regions page" )
92
90
93
- for table in tables :
94
- if not table .find_previous ("h3" ).text .strip () == "Available Regions" :
91
+ # Process the first table (which is the regions table)
92
+ table = tables [0 ]
93
+ table_rows = table .find_all ("tr" )[1 :] # Skip header row
94
+
95
+ for table_row in table_rows :
96
+ table_cells = table_row .find_all ("td" )
97
+ if len (table_cells ) < 2 : # We only need first two columns (Code and Name)
95
98
continue
99
+
100
+ region_code = table_cells [0 ].text .strip ()
101
+ region_name = table_cells [1 ].text .strip ()
96
102
97
- table_rows = table .find_all ("tr" )
98
-
99
- for table_row in table_rows :
100
- table_cells = table_row .find_all ("td" )
101
- if len (table_cells ) != 3 :
102
- continue
103
- region_code = table_cells [0 ].text .strip ()
104
- region_name = table_cells [1 ].text .strip ()
105
-
106
- if region_code not in all_enabled_regions :
107
- # Skip regions that are not enabled for the current account
108
- continue
109
-
110
- coordinates = self .retrieve_location (region_name )
111
- regions [f"{ Provider .AWS .value } :{ region_code } " ] = {
112
- "name" : region_name ,
113
- "provider" : Provider .AWS .value ,
114
- "code" : region_code ,
115
- "latitude" : coordinates [0 ],
116
- "longitude" : coordinates [1 ],
117
- }
118
- self ._aws_region_name_to_code [region_name ] = region_code
103
+ if region_code not in all_enabled_regions :
104
+ # Skip regions that are not enabled for the current account
105
+ continue
119
106
107
+ coordinates = self .retrieve_location (region_name )
108
+ print (f"Coordinates for { region_name } : { coordinates } " )
109
+ regions [f"{ Provider .AWS .value } :{ region_code } " ] = {
110
+ "name" : region_name ,
111
+ "provider" : Provider .AWS .value ,
112
+ "code" : region_code ,
113
+ "latitude" : coordinates [0 ],
114
+ "longitude" : coordinates [1 ],
115
+ }
116
+ self ._aws_region_name_to_code [region_name ] = region_code
120
117
return regions
121
118
122
119
def retrieve_integrationtest_regions (self ) -> dict [str , dict [str , Any ]]:
0 commit comments