Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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" {
Expand Down
15 changes: 11 additions & 4 deletions builtin/providers/google/resource_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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,
Expand Down Expand Up @@ -98,10 +104,11 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e

// Build the subnetwork parameters
subnetwork := &compute.Subnetwork{
Name: d.Get("name").(string),
Description: d.Get("description").(string),
IpCidrRange: d.Get("ip_cidr_range").(string),
Network: network,
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,
}

log.Printf("[DEBUG] Subnetwork insert request: %#v", subnetwork)
Expand Down
10 changes: 9 additions & 1 deletion builtin/providers/google/resource_compute_subnetwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The following arguments are supported:
In addition to the arguments listed above, the following attributes are exported:

* `network` - The network name or resource link to the parent
network of this subnetwork.
network of this subnetwork.

* `description` - Description of this subnetwork.

Expand All @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down