Skip to content

Commit 35f0774

Browse files
Add internal ipv6 prefix into compute network and subnetwork data source reference attribute (#9274) (#16267)
[upstream:a01e0e02d240ec508cca38a52a97fbe9018f48bc] Signed-off-by: Modular Magician <[email protected]>
1 parent cfe992c commit 35f0774

7 files changed

+32
-2
lines changed

.changelog/9274.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `internal_ipv6_range` to `data.google_compute_network` data source and `internal_ipv6_prefix` field to `data.google_compute_subnetwork` data source
3+
```

google/services/compute/data_source_google_compute_network.go

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func DataSourceGoogleComputeNetwork() *schema.Resource {
3030
Computed: true,
3131
},
3232

33+
"internal_ipv6_range": {
34+
Type: schema.TypeString,
35+
Computed: true,
36+
},
37+
3338
"self_link": {
3439
Type: schema.TypeString,
3540
Computed: true,
@@ -71,6 +76,9 @@ func dataSourceGoogleComputeNetworkRead(d *schema.ResourceData, meta interface{}
7176
if err := d.Set("gateway_ipv4", network.GatewayIPv4); err != nil {
7277
return fmt.Errorf("Error setting gateway_ipv4: %s", err)
7378
}
79+
if err := d.Set("internal_ipv6_range", network.InternalIpv6Range); err != nil {
80+
return fmt.Errorf("Error setting internal_ipv6_range: %s", err)
81+
}
7482
if err := d.Set("self_link", network.SelfLink); err != nil {
7583
return fmt.Errorf("Error setting self_link: %s", err)
7684
}

google/services/compute/data_source_google_compute_network_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name
4848
"id",
4949
"name",
5050
"description",
51+
"internal_ipv6_range",
5152
}
5253

5354
for _, attr_to_check := range network_attrs_to_test {
@@ -72,8 +73,10 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name
7273
func testAccDataSourceGoogleNetworkConfig(name string) string {
7374
return fmt.Sprintf(`
7475
resource "google_compute_network" "foobar" {
75-
name = "%s"
76-
description = "my-description"
76+
name = "%s"
77+
description = "my-description"
78+
enable_ula_internal_ipv6 = true
79+
auto_create_subnetworks = false
7780
}
7881
7982
data "google_compute_network" "my_network" {

google/services/compute/data_source_google_compute_subnetwork.go

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func DataSourceGoogleComputeSubnetwork() *schema.Resource {
3333
Type: schema.TypeString,
3434
Computed: true,
3535
},
36+
"internal_ipv6_prefix": {
37+
Type: schema.TypeString,
38+
Computed: true,
39+
},
3640
"private_ip_google_access": {
3741
Type: schema.TypeBool,
3842
Computed: true,
@@ -97,6 +101,9 @@ func dataSourceGoogleComputeSubnetworkRead(d *schema.ResourceData, meta interfac
97101
if err := d.Set("ip_cidr_range", subnetwork.IpCidrRange); err != nil {
98102
return fmt.Errorf("Error setting ip_cidr_range: %s", err)
99103
}
104+
if err := d.Set("internal_ipv6_prefix", subnetwork.InternalIpv6Prefix); err != nil {
105+
return fmt.Errorf("Error setting internal_ipv6_prefix: %s", err)
106+
}
100107
if err := d.Set("private_ip_google_access", subnetwork.PrivateIpGoogleAccess); err != nil {
101108
return fmt.Errorf("Error setting private_ip_google_access: %s", err)
102109
}

google/services/compute/data_source_google_compute_subnetwork_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func testAccDataSourceGoogleSubnetworkCheck(data_source_name string, resource_na
5151
"description",
5252
"ip_cidr_range",
5353
"private_ip_google_access",
54+
"internal_ipv6_prefix",
5455
"secondary_ip_range",
5556
}
5657

@@ -82,13 +83,17 @@ func testAccDataSourceGoogleSubnetwork(networkName, subnetName string) string {
8283
resource "google_compute_network" "foobar" {
8384
name = "%s"
8485
description = "my-description"
86+
enable_ula_internal_ipv6 = true
87+
auto_create_subnetworks = false
8588
}
8689
8790
resource "google_compute_subnetwork" "foobar" {
8891
name = "%s"
8992
description = "my-description"
9093
ip_cidr_range = "10.0.0.0/24"
9194
network = google_compute_network.foobar.self_link
95+
stack_type = "IPV4_IPV6"
96+
ipv6_access_type = "INTERNAL"
9297
private_ip_google_access = true
9398
secondary_ip_range {
9499
range_name = "tf-test-secondary-range"

website/docs/d/compute_network.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ In addition to the arguments listed above, the following attributes are exported
3838

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

41+
* `internal_ipv6_range` - The ula internal ipv6 range assigned to this network.
42+
4143
* `subnetworks_self_links` - the list of subnetworks which belong to the network
4244

4345
* `self_link` - The URI of the resource.

website/docs/d/compute_subnetwork.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ In addition to the arguments listed above, the following attributes are exported
4545
* `ip_cidr_range` - The IP address range that machines in this
4646
network are assigned to, represented as a CIDR block.
4747

48+
* `internal_ipv6_prefix` - The internal IPv6 address range that is assigned to this subnetwork.
49+
4850
* `gateway_address` - The IP address of the gateway.
4951

5052
* `private_ip_google_access` - Whether the VMs in this subnet

0 commit comments

Comments
 (0)