| 1 | package geo |
| 2 | |
| 3 | // AWSRegion is one AWS commercial region's metro-area point and the place |
| 4 | // name every surface shows for it (spec §14, copy C23 as approved in the |
| 5 | // nearest-region copy record). |
| 6 | // |
| 7 | // Source: AWS's official region list |
| 8 | // (https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html) |
| 9 | // as of 2026-10-01. Coordinates are each region's metro area, checked by |
| 10 | // hand; AWS publishes no facility locations, and tens of kilometres never |
| 11 | // change a choice between regions. |
| 12 | type AWSRegion struct { |
| 13 | Point |
| 14 | Place string |
| 15 | } |
| 16 | |
| 17 | var awsRegions = map[string]AWSRegion{ |
| 18 | "us-east-1": {Point{39.04, -77.49}, "US East · N. Virginia"}, |
| 19 | "us-east-2": {Point{39.96, -83.00}, "US East · Ohio"}, |
| 20 | "us-west-1": {Point{37.77, -122.42}, "US West · N. California"}, |
| 21 | "us-west-2": {Point{45.84, -119.70}, "US West · Oregon"}, |
| 22 | "ca-central-1": {Point{45.50, -73.57}, "Canada · Montréal"}, |
| 23 | "ca-west-1": {Point{51.05, -114.07}, "Canada · Calgary"}, |
| 24 | "mx-central-1": {Point{20.59, -100.39}, "Mexico · Querétaro"}, |
| 25 | "sa-east-1": {Point{-23.55, -46.63}, "Brazil · São Paulo"}, |
| 26 | "eu-west-1": {Point{53.35, -6.26}, "Ireland · Dublin"}, |
| 27 | "eu-west-2": {Point{51.51, -0.13}, "UK · London"}, |
| 28 | "eu-west-3": {Point{48.86, 2.35}, "France · Paris"}, |
| 29 | "eu-central-1": {Point{50.11, 8.68}, "Germany · Frankfurt"}, |
| 30 | "eu-central-2": {Point{47.37, 8.54}, "Switzerland · Zurich"}, |
| 31 | "eu-south-1": {Point{45.46, 9.19}, "Italy · Milan"}, |
| 32 | "eu-south-2": {Point{41.65, -0.89}, "Spain · Aragón"}, |
| 33 | "eu-north-1": {Point{59.33, 18.07}, "Sweden · Stockholm"}, |
| 34 | "il-central-1": {Point{32.09, 34.78}, "Israel · Tel Aviv"}, |
| 35 | "me-south-1": {Point{26.23, 50.59}, "Bahrain"}, |
| 36 | "me-central-1": {Point{25.20, 55.27}, "UAE"}, |
| 37 | "af-south-1": {Point{-33.92, 18.42}, "South Africa · Cape Town"}, |
| 38 | "ap-south-1": {Point{19.08, 72.88}, "India · Mumbai"}, |
| 39 | "ap-south-2": {Point{17.39, 78.49}, "India · Hyderabad"}, |
| 40 | "ap-east-1": {Point{22.32, 114.17}, "Hong Kong"}, |
| 41 | "ap-east-2": {Point{25.03, 121.57}, "Taiwan · Taipei"}, |
| 42 | "ap-southeast-1": {Point{1.35, 103.82}, "Singapore"}, |
| 43 | "ap-southeast-2": {Point{-33.87, 151.21}, "Australia · Sydney"}, |
| 44 | "ap-southeast-3": {Point{-6.21, 106.85}, "Indonesia · Jakarta"}, |
| 45 | "ap-southeast-4": {Point{-37.81, 144.96}, "Australia · Melbourne"}, |
| 46 | "ap-southeast-5": {Point{3.14, 101.69}, "Malaysia"}, |
| 47 | "ap-southeast-6": {Point{-36.85, 174.76}, "New Zealand · Auckland"}, |
| 48 | "ap-southeast-7": {Point{13.76, 100.50}, "Thailand · Bangkok"}, |
| 49 | "ap-northeast-1": {Point{35.68, 139.69}, "Japan · Tokyo"}, |
| 50 | "ap-northeast-2": {Point{37.57, 126.98}, "South Korea · Seoul"}, |
| 51 | "ap-northeast-3": {Point{34.69, 135.50}, "Japan · Osaka"}, |
| 52 | } |
| 53 | |
| 54 | // LookupAWSRegion finds a region in the table. |
| 55 | func LookupAWSRegion(code string) (AWSRegion, bool) { |
| 56 | r, ok := awsRegions[code] |
| 57 | return r, ok |
| 58 | } |
| 59 | |
| 60 | func tablePoint(code string) (Point, bool) { |
| 61 | r, ok := awsRegions[code] |
| 62 | return r.Point, ok |
| 63 | } |
| 64 | |
| 65 | // Nearest is NearestWith over the shipped table. |
| 66 | func Nearest(p Point, cands []Candidate) (string, bool) { |
| 67 | return NearestWith(p, cands, tablePoint) |
| 68 | } |
| 69 | |
| 70 | // PlaceName is the table's place for awsRegion, or fallback (the bare |
| 71 | // placement code) for a region the table does not know. |
| 72 | func PlaceName(awsRegion, fallback string) string { |
| 73 | if r, ok := awsRegions[awsRegion]; ok { |
| 74 | return r.Place |
| 75 | } |
| 76 | return fallback |
| 77 | } |
| 78 | |