@@ -690,6 +690,48 @@ func determineOrg(ctx context.Context, config *appconfig.Config) (*fly.Organizat
690690 return & org , "specified on the command line" , nil
691691}
692692
693+ // Map of deprecated region codes and their consolidated replacements
694+ var deprecatedRegionReplacements = map [string ]string {
695+ "atl" : "dfw" ,
696+ "den" : "dfw" ,
697+ "mia" : "dfw" ,
698+ "gdl" : "dfw" ,
699+ "qro" : "dfw" ,
700+ "bos" : "ewr" ,
701+ "phx" : "lax" ,
702+ "sea" : "sjc" ,
703+ "yul" : "yyz" ,
704+ "waw" : "ams" ,
705+ "mad" : "cdg" ,
706+ "otp" : "fra" ,
707+ "bog" : "gru" ,
708+ "gig" : "gru" ,
709+ "scl" : "gru" ,
710+ "eze" : "gru" ,
711+ "hkg" : "sin" ,
712+ }
713+
714+ // Check if a region is deprecated and return the replacement region
715+ func remapDeprecatedRegion (ctx context.Context , region * fly.Region ) (* fly.Region , error ) {
716+ if region == nil || ! region .Deprecated {
717+ return region , nil
718+ }
719+
720+ replacementCode , ok := deprecatedRegionReplacements [region .Code ]
721+ if ! ok {
722+ // If there's no definied replacement, return and error
723+ return nil , fmt .Errorf ("region %s is deprecated. Please use a supported region." , region .Code )
724+ }
725+
726+ // Get the replacement region
727+ replacementRegion , err := getRegionByCode (ctx , replacementCode )
728+ if err != nil {
729+ return nil , fmt .Errorf ("failed to get replacement region %s for deprecated region %s: %w" , replacementCode , region .Code , err )
730+ }
731+
732+ return replacementRegion , nil
733+ }
734+
693735// determineRegion returns the region to use for a new app. In order, it tries:
694736// 1. the primary_region field of the config, if one exists
695737// 2. the region specified on the command line, if specified
@@ -708,6 +750,15 @@ func determineRegion(ctx context.Context, config *appconfig.Config, paidPlan boo
708750 // TODO(allison): does this return paid regions for free orgs?
709751 closestRegion , closestRegionErr := client .GetNearestRegion (ctx )
710752
753+ // Remap the closest region if it's deprecated
754+ if closestRegionErr == nil && closestRegion != nil {
755+ remappedRegion , remapErr := remapDeprecatedRegion (ctx , closestRegion )
756+ if remapErr == nil {
757+ closestRegion = remappedRegion
758+ }
759+ // If remapping fails, it'll use the original region and hit the "unknown region" error
760+ }
761+
711762 if regionCode != "" {
712763 region , err := getRegionByCode (ctx , regionCode )
713764 if err != nil {
0 commit comments