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

Added internalIpv6Prefix attribute on Subnetwork resource #6306

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/8985.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added output field `internal_ipv6_prefix` to `google_compute_subnetwork` resource
```
12 changes: 12 additions & 0 deletions google-beta/services/compute/resource_compute_subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ If not specified IPV4_ONLY will be used. Possible values: ["IPV4_ONLY", "IPV4_IP
Description: `The gateway address for default routes to reach destination addresses
outside this subnetwork.`,
},
"internal_ipv6_prefix": {
Type: schema.TypeString,
Computed: true,
Description: `The internal IPv6 address range that is assigned to this subnetwork.`,
},
"ipv6_cidr_range": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -589,6 +594,9 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("ipv6_cidr_range", flattenComputeSubnetworkIpv6CidrRange(res["ipv6CidrRange"], d, config)); err != nil {
return fmt.Errorf("Error reading Subnetwork: %s", err)
}
if err := d.Set("internal_ipv6_prefix", flattenComputeSubnetworkInternalIpv6Prefix(res["internalIpv6Prefix"], d, config)); err != nil {
return fmt.Errorf("Error reading Subnetwork: %s", err)
}
if err := d.Set("external_ipv6_prefix", flattenComputeSubnetworkExternalIpv6Prefix(res["externalIpv6Prefix"], d, config)); err != nil {
return fmt.Errorf("Error reading Subnetwork: %s", err)
}
Expand Down Expand Up @@ -1174,6 +1182,10 @@ func flattenComputeSubnetworkIpv6CidrRange(v interface{}, d *schema.ResourceData
return v
}

func flattenComputeSubnetworkInternalIpv6Prefix(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenComputeSubnetworkExternalIpv6Prefix(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,29 @@ func TestAccComputeSubnetwork_ipv6(t *testing.T) {
})
}

func TestAccComputeSubnetwork_internal_ipv6(t *testing.T) {
t.Parallel()

cnName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
subnetworkName := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeSubnetworkDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeSubnetwork_internal_ipv6(cnName, subnetworkName),
},
{
ResourceName: "google_compute_subnetwork.subnetwork",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccCheckComputeSubnetworkExists(t *testing.T, n string, subnetwork *compute.Subnetwork) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down Expand Up @@ -797,3 +820,22 @@ resource "google_compute_subnetwork" "subnetwork" {
}
`, cnName, subnetworkName)
}

func testAccComputeSubnetwork_internal_ipv6(cnName, subnetworkName string) string {
return fmt.Sprintf(`
resource "google_compute_network" "custom-test" {
name = "%s"
auto_create_subnetworks = false
enable_ula_internal_ipv6 = true
}

resource "google_compute_subnetwork" "subnetwork" {
name = "%s"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = google_compute_network.custom-test.self_link
stack_type = "IPV4_IPV6"
ipv6_access_type = "INTERNAL"
}
`, cnName, subnetworkName)
}
3 changes: 3 additions & 0 deletions website/docs/r/compute_subnetwork.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ In addition to the arguments listed above, the following computed attributes are
* `ipv6_cidr_range` -
The range of internal IPv6 addresses that are owned by this subnetwork.

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

* `external_ipv6_prefix` -
The range of external IPv6 addresses that are owned by this subnetwork.
* `self_link` - The URI of the created resource.
Expand Down