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

View File

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

View File

@ -58,6 +58,12 @@ func resourceComputeSubnetwork() *schema.Resource {
ForceNew: true, ForceNew: true,
}, },
"private_ip_google_access": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"self_link": &schema.Schema{ "self_link": &schema.Schema{
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
@ -97,10 +103,11 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e
// Build the subnetwork parameters // Build the subnetwork parameters
subnetwork := &compute.Subnetwork{ subnetwork := &compute.Subnetwork{
Name: d.Get("name").(string), Name: d.Get("name").(string),
Description: d.Get("description").(string), Description: d.Get("description").(string),
IpCidrRange: d.Get("ip_cidr_range").(string), IpCidrRange: d.Get("ip_cidr_range").(string),
Network: network, PrivateIpGoogleAccess: d.Get("private_ip_google_access").(bool),
Network: network,
} }
log.Printf("[DEBUG] Subnetwork insert request: %#v", subnetwork) log.Printf("[DEBUG] Subnetwork insert request: %#v", subnetwork)

View File

@ -102,4 +102,12 @@ resource "google_compute_subnetwork" "network-ref-by-name" {
network = "${google_compute_network.custom-test.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

@ -38,7 +38,7 @@ The following arguments are supported:
In addition to the arguments listed above, the following attributes are exported: In addition to the arguments listed above, the following attributes are exported:
* `network` - The network name or resource link to the parent * `network` - The network name or resource link to the parent
network of this subnetwork. network of this subnetwork.
* `description` - Description of this subnetwork. * `description` - Description of this subnetwork.
@ -47,4 +47,8 @@ In addition to the arguments listed above, the following attributes are exported
* `gateway_address` - The IP address of the gateway. * `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. * `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 * `region` - (Optional) The region this subnetwork will be created in. If
unspecified, this defaults to the region configured in the provider. 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 ## Attributes Reference
In addition to the arguments listed above, the following computed attributes are In addition to the arguments listed above, the following computed attributes are