github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/data_source_aws_elb_hosted_zone_id.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/helper/schema" 7 ) 8 9 // See https://github.com/fog/fog-aws/pull/332/files 10 // This list isn't exposed by AWS - it's been found through 11 // trouble solving 12 var elbHostedZoneIdPerRegionMap = map[string]string{ 13 "ap-northeast-1": "Z14GRHDCWA56QT", 14 "ap-northeast-2": "ZWKZPGTI48KDX", 15 "ap-south-1": "ZP97RAFLXTNZK", 16 "ap-southeast-1": "Z1LMS91P8CMLE5", 17 "ap-southeast-2": "Z1GM3OXH4ZPM65", 18 "ca-central-1": "ZQSVJUPU6J1EY", 19 "eu-central-1": "Z215JYRZR1TBD5", 20 "eu-west-1": "Z32O12XQLNTSW2", 21 "eu-west-2": "ZHURV8PSTC4K8", 22 "us-east-1": "Z35SXDOTRQ7X7K", 23 "us-east-2": "Z3AADJGX6KTTL2", 24 "us-west-1": "Z368ELLRRE2KJ0", 25 "us-west-2": "Z1H1FL5HABSF5", 26 "sa-east-1": "Z2P70J7HTTTPLU", 27 } 28 29 func dataSourceAwsElbHostedZoneId() *schema.Resource { 30 return &schema.Resource{ 31 Read: dataSourceAwsElbHostedZoneIdRead, 32 33 Schema: map[string]*schema.Schema{ 34 "region": { 35 Type: schema.TypeString, 36 Optional: true, 37 }, 38 }, 39 } 40 } 41 42 func dataSourceAwsElbHostedZoneIdRead(d *schema.ResourceData, meta interface{}) error { 43 region := meta.(*AWSClient).region 44 if v, ok := d.GetOk("region"); ok { 45 region = v.(string) 46 } 47 48 if zoneId, ok := elbHostedZoneIdPerRegionMap[region]; ok { 49 d.SetId(zoneId) 50 return nil 51 } 52 53 return fmt.Errorf("Unknown region (%q)", region) 54 }