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

Add internal ipv6 prefix into compute network and subnetwork data source reference attribute #16267

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
3 changes: 3 additions & 0 deletions .changelog/9274.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `internal_ipv6_range` to `data.google_compute_network` data source and `internal_ipv6_prefix` field to `data.google_compute_subnetwork` data source
```
8 changes: 8 additions & 0 deletions google/services/compute/data_source_google_compute_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func DataSourceGoogleComputeNetwork() *schema.Resource {
Computed: true,
},

"internal_ipv6_range": {
Type: schema.TypeString,
Computed: true,
},

"self_link": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -71,6 +76,9 @@ func dataSourceGoogleComputeNetworkRead(d *schema.ResourceData, meta interface{}
if err := d.Set("gateway_ipv4", network.GatewayIPv4); err != nil {
return fmt.Errorf("Error setting gateway_ipv4: %s", err)
}
if err := d.Set("internal_ipv6_range", network.InternalIpv6Range); err != nil {
return fmt.Errorf("Error setting internal_ipv6_range: %s", err)
}
if err := d.Set("self_link", network.SelfLink); err != nil {
return fmt.Errorf("Error setting self_link: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name
"id",
"name",
"description",
"internal_ipv6_range",
}

for _, attr_to_check := range network_attrs_to_test {
Expand All @@ -72,8 +73,10 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name
func testAccDataSourceGoogleNetworkConfig(name string) string {
return fmt.Sprintf(`
resource "google_compute_network" "foobar" {
name = "%s"
description = "my-description"
name = "%s"
description = "my-description"
enable_ula_internal_ipv6 = true
auto_create_subnetworks = false
}

data "google_compute_network" "my_network" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func DataSourceGoogleComputeSubnetwork() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"internal_ipv6_prefix": {
Type: schema.TypeString,
Computed: true,
},
"private_ip_google_access": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -97,6 +101,9 @@ func dataSourceGoogleComputeSubnetworkRead(d *schema.ResourceData, meta interfac
if err := d.Set("ip_cidr_range", subnetwork.IpCidrRange); err != nil {
return fmt.Errorf("Error setting ip_cidr_range: %s", err)
}
if err := d.Set("internal_ipv6_prefix", subnetwork.InternalIpv6Prefix); err != nil {
return fmt.Errorf("Error setting internal_ipv6_prefix: %s", err)
}
if err := d.Set("private_ip_google_access", subnetwork.PrivateIpGoogleAccess); err != nil {
return fmt.Errorf("Error setting private_ip_google_access: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func testAccDataSourceGoogleSubnetworkCheck(data_source_name string, resource_na
"description",
"ip_cidr_range",
"private_ip_google_access",
"internal_ipv6_prefix",
"secondary_ip_range",
}

Expand Down Expand Up @@ -82,13 +83,17 @@ func testAccDataSourceGoogleSubnetwork(networkName, subnetName string) string {
resource "google_compute_network" "foobar" {
name = "%s"
description = "my-description"
enable_ula_internal_ipv6 = true
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "foobar" {
name = "%s"
description = "my-description"
ip_cidr_range = "10.0.0.0/24"
network = google_compute_network.foobar.self_link
stack_type = "IPV4_IPV6"
ipv6_access_type = "INTERNAL"
private_ip_google_access = true
secondary_ip_range {
range_name = "tf-test-secondary-range"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/compute_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ In addition to the arguments listed above, the following attributes are exported

* `gateway_ipv4` - The IP address of the gateway.

* `internal_ipv6_range` - The ula internal ipv6 range assigned to this network.

* `subnetworks_self_links` - the list of subnetworks which belong to the network

* `self_link` - The URI of the resource.
2 changes: 2 additions & 0 deletions website/docs/d/compute_subnetwork.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ In addition to the arguments listed above, the following attributes are exported
* `ip_cidr_range` - The IP address range that machines in this
network are assigned to, represented as a CIDR block.

* `internal_ipv6_prefix` - The internal IPv6 address range that is assigned to this subnetwork.

* `gateway_address` - The IP address of the gateway.

* `private_ip_google_access` - Whether the VMs in this subnet
Expand Down