Skip to content

Commit

Permalink
Add support for IPv6 addresses with the google_compute_external_vpn_…
Browse files Browse the repository at this point in the history
…gateway terraform resource (GoogleCloudPlatform#11982)
  • Loading branch information
abhijeetkjha-google authored and akshat-jindal-nit committed Nov 18, 2024
1 parent 3cfdc98 commit b0c0c6e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mmv1/products/compute/ExternalVpnGateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,12 @@ properties:
Only IPv4 is supported. This IP address can be either from
your on-premise gateway or another Cloud provider's VPN gateway,
it cannot be an IP address from Google Compute Engine.
- name: 'ipv6Address'
type: String
description: |
IPv6 address of the interface in the external VPN gateway. This IPv6
address can be either from your on-premise gateway or another Cloud
provider's VPN gateway, it cannot be an IP address from Google Compute
Engine. Must specify an IPv6 address (not IPV4-mapped) using any format
described in RFC 4291 (e.g. 2001:db8:0:0:2d9:51:0:0). The output format
is RFC 5952 format (e.g. 2001:db8::2d9:51:0:0).
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,42 @@ resource "google_compute_external_vpn_gateway" "external_gateway" {
}
`, suffix, key, value)
}

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

rnd := acctest.RandString(t, 10)
resourceName := "google_compute_external_vpn_gateway.external_gateway"

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: computeExternalVPNGatewayIpv6AddressConfig(rnd, "2001:db8:abcd:1234:5678:90ab:cdef:1234"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "interface.0.ipv6_address", "2001:db8:abcd:1234:5678:90ab:cdef:1234"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func computeExternalVPNGatewayIpv6AddressConfig(suffix, ipv6_address string) string {
return fmt.Sprintf(`
resource "google_compute_external_vpn_gateway" "external_gateway" {
name = "tf-test-external-gateway-%s"
redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT"
description = "An externally managed VPN gateway"
interface {
id = 0
ipv6_address = "%s"
}
}
`, suffix, ipv6_address)
}

0 comments on commit b0c0c6e

Please sign in to comment.