forked from hashicorp/terraform-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hosted_zone_data_source.go
66 lines (57 loc) · 2.04 KB
/
hosted_zone_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
package elasticbeanstalk
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#elasticbeanstalk_region
var HostedZoneIDs = map[string]string{
endpoints.AfSouth1RegionID: "Z1EI3BVKMKK4AM",
endpoints.ApSoutheast1RegionID: "Z16FZ9L249IFLT",
endpoints.ApSoutheast2RegionID: "Z2PCDNR3VC2G1N",
endpoints.ApEast1RegionID: "ZPWYUBWRU171A",
endpoints.ApNortheast1RegionID: "Z1R25G3KIG2GBW",
endpoints.ApNortheast2RegionID: "Z3JE5OI70TWKCP",
endpoints.ApNortheast3RegionID: "ZNE5GEY1TIAGY",
endpoints.ApSouth1RegionID: "Z18NTBI3Y7N9TZ",
endpoints.CaCentral1RegionID: "ZJFCZL7SSZB5I",
endpoints.EuCentral1RegionID: "Z1FRNW7UH4DEZJ",
endpoints.EuNorth1RegionID: "Z23GO28BZ5AETM",
endpoints.EuSouth1RegionID: "Z10VDYYOA2JFKM",
endpoints.EuWest1RegionID: "Z2NYPWQ7DFZAZH",
endpoints.EuWest2RegionID: "Z1GKAAAUGATPF1",
endpoints.EuWest3RegionID: "Z5WN6GAYWG5OB",
endpoints.MeSouth1RegionID: "Z2BBTEKR2I36N2",
endpoints.SaEast1RegionID: "Z10X7K2B4QSOFV",
endpoints.UsEast1RegionID: "Z117KPS5GTRQ2G",
endpoints.UsEast2RegionID: "Z14LCN19Q5QHIC",
endpoints.UsWest1RegionID: "Z1LQECGX5PH1X",
endpoints.UsWest2RegionID: "Z38NKT9BP95V3O",
endpoints.UsGovEast1RegionID: "Z35TSARG0EJ4VU",
endpoints.UsGovWest1RegionID: "Z4KAURWC4UUUG",
}
func DataSourceHostedZone() *schema.Resource {
return &schema.Resource{
Read: dataSourceHostedZoneRead,
Schema: map[string]*schema.Schema{
"region": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
func dataSourceHostedZoneRead(d *schema.ResourceData, meta interface{}) error {
region := meta.(*conns.AWSClient).Region
if v, ok := d.GetOk("region"); ok {
region = v.(string)
}
zoneID, ok := HostedZoneIDs[region]
if !ok {
return fmt.Errorf("Unsupported region: %s", region)
}
d.SetId(zoneID)
d.Set("region", region)
return nil
}