forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosted_zone_id_data_source.go
67 lines (59 loc) · 2.24 KB
/
hosted_zone_id_data_source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package elb
import (
"fmt"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-aws/internal/conns"
)
// See http://docs.aws.amazon.com/general/latest/gr/rande.html#elb_region
// See https://docs.amazonaws.cn/en_us/general/latest/gr/rande.html#elb_region
var HostedZoneIdPerRegionMap = map[string]string{
endpoints.AfSouth1RegionID: "Z268VQBMOI5EKX",
endpoints.ApEast1RegionID: "Z3DQVH9N71FHZ0",
endpoints.ApNortheast1RegionID: "Z14GRHDCWA56QT",
endpoints.ApNortheast2RegionID: "ZWKZPGTI48KDX",
endpoints.ApNortheast3RegionID: "Z5LXEXXYW11ES",
endpoints.ApSouth1RegionID: "ZP97RAFLXTNZK",
endpoints.ApSoutheast1RegionID: "Z1LMS91P8CMLE5",
endpoints.ApSoutheast2RegionID: "Z1GM3OXH4ZPM65",
endpoints.ApSoutheast3RegionID: "Z08888821HLRG5A9ZRTER",
endpoints.CaCentral1RegionID: "ZQSVJUPU6J1EY",
endpoints.CnNorth1RegionID: "Z1GDH35T77C1KE",
endpoints.CnNorthwest1RegionID: "ZM7IZAIOVVDZF",
endpoints.EuCentral1RegionID: "Z215JYRZR1TBD5",
endpoints.EuNorth1RegionID: "Z23TAZ6LKFMNIO",
endpoints.EuSouth1RegionID: "Z3ULH7SSC9OV64",
endpoints.EuWest1RegionID: "Z32O12XQLNTSW2",
endpoints.EuWest2RegionID: "ZHURV8PSTC4K8",
endpoints.EuWest3RegionID: "Z3Q77PNBQS71R4",
endpoints.MeSouth1RegionID: "ZS929ML54UICD",
endpoints.SaEast1RegionID: "Z2P70J7HTTTPLU",
endpoints.UsEast1RegionID: "Z35SXDOTRQ7X7K",
endpoints.UsEast2RegionID: "Z3AADJGX6KTTL2",
endpoints.UsGovEast1RegionID: "Z166TLBEWOO7G0",
endpoints.UsGovWest1RegionID: "Z33AYJ8TM3BH4J",
endpoints.UsWest1RegionID: "Z368ELLRRE2KJ0",
endpoints.UsWest2RegionID: "Z1H1FL5HABSF5",
}
func DataSourceHostedZoneID() *schema.Resource {
return &schema.Resource{
Read: dataSourceHostedZoneIDRead,
Schema: map[string]*schema.Schema{
"region": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
func dataSourceHostedZoneIDRead(d *schema.ResourceData, meta interface{}) error {
region := meta.(*conns.AWSClient).Region
if v, ok := d.GetOk("region"); ok {
region = v.(string)
}
if zoneId, ok := HostedZoneIdPerRegionMap[region]; ok {
d.SetId(zoneId)
return nil
}
return fmt.Errorf("Unknown region (%q)", region)
}