github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/builder/amazon/common/regions.go (about) 1 package common 2 3 // aws ec2 describe-regions --query 'Regions[].{Name:RegionName}' --output text | sed 's/\(.*\)/"\1",/' | sort 4 func listEC2Regions() []string { 5 return []string{ 6 "ap-northeast-1", 7 "ap-northeast-2", 8 "ap-northeast-3", 9 "ap-south-1", 10 "ap-southeast-1", 11 "ap-southeast-2", 12 "ca-central-1", 13 "eu-central-1", 14 "eu-west-1", 15 "eu-west-2", 16 "eu-west-3", 17 "sa-east-1", 18 "us-east-1", 19 "us-east-2", 20 "us-west-1", 21 "us-west-2", 22 // not part of autogenerated list 23 "us-gov-west-1", 24 "cn-north-1", 25 "cn-northwest-1", 26 } 27 } 28 29 // ValidateRegion returns true if the supplied region is a valid AWS 30 // region and false if it's not. 31 func ValidateRegion(region string) bool { 32 for _, valid := range listEC2Regions() { 33 if region == valid { 34 return true 35 } 36 } 37 return false 38 }