github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/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-south-1", 9 "ap-southeast-1", 10 "ap-southeast-2", 11 "ca-central-1", 12 "eu-central-1", 13 "eu-west-1", 14 "eu-west-2", 15 "sa-east-1", 16 "us-east-1", 17 "us-east-2", 18 "us-west-1", 19 "us-west-2", 20 // not part of autogenerated list 21 "us-gov-west-1", 22 "cn-north-1", 23 } 24 } 25 26 // ValidateRegion returns true if the supplied region is a valid AWS 27 // region and false if it's not. 28 func ValidateRegion(region string) bool { 29 for _, valid := range listEC2Regions() { 30 if region == valid { 31 return true 32 } 33 } 34 return false 35 }