Skip to content

Commit

Permalink
Add internal ipv6 prefix into compute network and subnetwork data sou…
Browse files Browse the repository at this point in the history
…rce reference attribute (#9274)

Co-authored-by: Riley Karson <[email protected]>
  • Loading branch information
2 people authored and zli82016 committed Oct 20, 2023
1 parent b2d47a9 commit a321782
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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 @@ -69,6 +74,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 @@ -46,6 +46,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 @@ -70,8 +71,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 @@ -36,6 +36,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 @@ -100,6 +104,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 @@ -49,6 +49,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 @@ -80,13 +81,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
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.
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

0 comments on commit a321782

Please sign in to comment.