forked from hashicorp/terraform-provider-google-beta
/
data_source_compute_lb_ip_ranges.go
53 lines (44 loc) · 1.29 KB
/
data_source_compute_lb_ip_ranges.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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package compute
import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func DataSourceGoogleComputeLbIpRanges() *schema.Resource {
return &schema.Resource{
Read: dataSourceGoogleComputeLbIpRangesRead,
Schema: map[string]*schema.Schema{
"network": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"http_ssl_tcp_internal": {
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
},
}
}
func dataSourceGoogleComputeLbIpRangesRead(d *schema.ResourceData, meta interface{}) error {
d.SetId("compute-lb-ip-ranges")
// https://cloud.google.com/compute/docs/load-balancing/health-checks#health_check_source_ips_and_firewall_rules
networkIpRanges := []string{
"209.85.152.0/22",
"209.85.204.0/22",
"35.191.0.0/16",
}
if err := d.Set("network", networkIpRanges); err != nil {
return fmt.Errorf("Error setting network: %s", err)
}
httpSslTcpInternalRanges := []string{
"130.211.0.0/22",
"35.191.0.0/16",
}
if err := d.Set("http_ssl_tcp_internal", httpSslTcpInternalRanges); err != nil {
return fmt.Errorf("Error setting http_ssl_tcp_internal: %s", err)
}
return nil
}