provider/google: Add support for privateIpGoogleAccess on subnetworks (#14234)

This commit is contained in:
Matt Robenolt 2017-05-18 13:35:02 -07:00 committed by Dana Hoffman
parent 208199a554
commit 27927ddc2c
6 changed files with 36 additions and 6 deletions

View File

@ -29,6 +29,10 @@ func dataSourceGoogleComputeSubnetwork() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"private_ip_google_access": &schema.Schema{
Type: schema.TypeBool,
Computed: true,
},
"network": &schema.Schema{
Type: schema.TypeString,
Computed: true,
@ -75,6 +79,7 @@ func dataSourceGoogleComputeSubnetworkRead(d *schema.ResourceData, meta interfac
}
d.Set("ip_cidr_range", subnetwork.IpCidrRange)
d.Set("private_ip_google_access", subnetwork.PrivateIpGoogleAccess)
d.Set("self_link", subnetwork.SelfLink)
d.Set("description", subnetwork.Description)
d.Set("gateway_address", subnetwork.GatewayAddress)

View File

@ -45,6 +45,7 @@ func testAccDataSourceGoogleSubnetworkCheck(data_source_name string, resource_na
"description",
"ip_cidr_range",
"network",
"private_ip_google_access",
}
for _, attr_to_check := range subnetwork_attrs_to_test {
@ -73,6 +74,7 @@ resource "google_compute_subnetwork" "foobar" {
description = "my-description"
ip_cidr_range = "10.0.0.0/24"
network = "${google_compute_network.foobar.self_link}"
private_ip_google_access = true
}
data "google_compute_subnetwork" "my_subnetwork" {

View File

@ -58,6 +58,12 @@ func resourceComputeSubnetwork() *schema.Resource {
ForceNew: true,
},
"private_ip_google_access": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"self_link": &schema.Schema{
Type: schema.TypeString,
Computed: true,
@ -100,6 +106,7 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e
Name: d.Get("name").(string),
Description: d.Get("description").(string),
IpCidrRange: d.Get("ip_cidr_range").(string),
PrivateIpGoogleAccess: d.Get("private_ip_google_access").(bool),
Network: network,
}

View File

@ -102,4 +102,12 @@ resource "google_compute_subnetwork" "network-ref-by-name" {
network = "${google_compute_network.custom-test.name}"
}
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
resource "google_compute_subnetwork" "network-with-private-google-access" {
name = "subnetwork-test-%s"
ip_cidr_range = "10.2.0.0/16"
region = "us-central1"
network = "${google_compute_network.custom-test.self_link}"
private_ip_google_access = true
}
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))

View File

@ -47,4 +47,8 @@ In addition to the arguments listed above, the following attributes are exported
* `gateway_address` - The IP address of the gateway.
* `private_ip_google_access` - Whether the VMs in this subnet
can access Google services without assigned external IP
addresses.
* `self_link` - The URI of the created resource.

View File

@ -45,6 +45,10 @@ The following arguments are supported:
* `region` - (Optional) The region this subnetwork will be created in. If
unspecified, this defaults to the region configured in the provider.
* `private_ip_google_access` - Whether the VMs in this subnet
can access Google services without assigned external IP
addresses.
## Attributes Reference
In addition to the arguments listed above, the following computed attributes are