github.com/defang-io/defang/src@v0.0.0-20240505002154-bdf411911834/pkg/clouds/aws/region/region.go (about)

     1  package region
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/defang-io/defang/src/pkg/clouds/aws"
     7  )
     8  
     9  type Region = aws.Region
    10  
    11  const (
    12  	AFSouth1     Region = "af-south-1"
    13  	APEast1      Region = "ap-east-1"
    14  	APNortheast1 Region = "ap-northeast-1"
    15  	APNortheast2 Region = "ap-northeast-2"
    16  	APNortheast3 Region = "ap-northeast-3"
    17  	APSouth1     Region = "ap-south-1"
    18  	APSouth2     Region = "ap-south-2"
    19  	APSoutheast1 Region = "ap-southeast-1"
    20  	APSoutheast2 Region = "ap-southeast-2"
    21  	APSoutheast3 Region = "ap-southeast-3"
    22  	APSoutheast4 Region = "ap-southeast-4"
    23  	CACentral    Region = "ca-central-1"
    24  	CNNorth1     Region = "cn-north-1"
    25  	CNNorthwest1 Region = "cn-northwest-1"
    26  	EUCentral1   Region = "eu-central-1"
    27  	EUCentral2   Region = "eu-central-2"
    28  	EUNorth1     Region = "eu-north-1"
    29  	EUSouth1     Region = "eu-south-1"
    30  	EUSouth2     Region = "eu-south-2"
    31  	EUWest1      Region = "eu-west-1"
    32  	EUWest2      Region = "eu-west-2"
    33  	EUWest3      Region = "eu-west-3"
    34  	MECentral1   Region = "me-central-1"
    35  	MESouth1     Region = "me-south-1"
    36  	SAEast1      Region = "sa-east-1"
    37  	USGovEast1   Region = "us-gov-east-1"
    38  	USGovWest1   Region = "us-gov-west-1"
    39  	USEast1      Region = "us-east-1"
    40  	USEast2      Region = "us-east-2"
    41  	USWest1      Region = "us-west-1"
    42  	USWest2      Region = "us-west-2"
    43  )
    44  
    45  func FromArn(arn string) Region {
    46  	parts := strings.Split(arn, ":")
    47  	if len(parts) < 6 || parts[0] != "arn" {
    48  		panic("invalid ARN")
    49  	}
    50  	return Region(parts[3])
    51  }