Skip to content

Adding New Subnet-Mode To PDP Mode Field #9630

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

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/13298.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: added `EXTERNAL_IPV6_SUBNETWORK_CREATION` as a supported value for the `mode` field in `google_compute_public_delegated_prefix` resource
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import (
// Since we only have access to one test prefix range we cannot run tests in parallel
func TestAccComputePublicPrefixes(t *testing.T) {
testCases := map[string]func(t *testing.T){
"delegated_prefix": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesBasicTest,
"advertised_prefix": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest,
"public_delegated_prefixes_ipv6": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesIpv6Test,
"public_advertised_prefixes_pdp_scope": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeTest,
"delegated_prefix": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesBasicTest,
"advertised_prefix": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest,
"public_delegated_prefixes_ipv6": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesIpv6Test,
"public_advertised_prefixes_pdp_scope": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeTest,
"public_delegated_prefix_ipv6_subnet_mode": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixIpv6SubnetModeTest,
}

for name, tc := range testCases {
Expand Down Expand Up @@ -213,6 +214,60 @@ resource "google_compute_public_delegated_prefix" "subprefix" {
`, context)
}

func testAccComputePublicDelegatedPrefix_publicDelegatedPrefixIpv6SubnetModeTest(t *testing.T) {
context := map[string]interface{}{
"description": envvar.GetTestPublicAdvertisedPrefixDescriptionFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputePublicDelegatedPrefixDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputePublicDelegatedPrefix_publicDelegatedPrefixIpv6SubnetModeExample(context),
},
{
ResourceName: "google_compute_public_delegated_prefix.prefix",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}

func testAccComputePublicDelegatedPrefix_publicDelegatedPrefixIpv6SubnetModeExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_compute_public_advertised_prefix" "advertised" {
name = "tf-test-ipv6-pap%{random_suffix}"
description = "%{description}"
dns_verification_ip = "2001:db8::"
ip_cidr_range = "2001:db8::/32"
pdp_scope = "REGIONAL"
}

resource "google_compute_public_delegated_prefix" "prefix" {
name = "tf-test-root-pdp%{random_suffix}"
description = "test-delegation-mode-pdp"
region = "us-east1"
ip_cidr_range = "2001:db8::/40"
parent_prefix = google_compute_public_advertised_prefix.advertised.id
mode = "DELEGATION"
}

resource "google_compute_public_delegated_prefix" "subprefix" {
name = "tf-test-sub-pdp%{random_suffix}"
description = "test-subnet-mode-pdp"
region = "us-east1"
ip_cidr_range = "2001:db8::/48"
parent_prefix = google_compute_public_delegated_prefix.prefix.id
mode = "EXTERNAL_IPV6_SUBNETWORK_CREATION"
}
`, context)
}

func testAccCheckComputePublicDelegatedPrefixDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ except the last character, which cannot be a dash.`,
},
"allocatable_prefix_length": {
Type: schema.TypeInt,
Computed: true,
Optional: true,
ForceNew: true,
Description: `The allocatable prefix length supported by this public delegated prefix. This field is optional and cannot be set for prefixes in DELEGATION mode. It cannot be set for IPv4 prefixes either, and it always defaults to 32.`,
Expand All @@ -106,9 +107,9 @@ except the last character, which cannot be a dash.`,
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: verify.ValidateEnum([]string{"DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION", ""}),
ValidateFunc: verify.ValidateEnum([]string{"DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION", "EXTERNAL_IPV6_SUBNETWORK_CREATION", ""}),
Description: `Specifies the mode of this IPv6 PDP. MODE must be one of: DELEGATION,
EXTERNAL_IPV6_FORWARDING_RULE_CREATION. Possible values: ["DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION"]`,
EXTERNAL_IPV6_FORWARDING_RULE_CREATION and EXTERNAL_IPV6_SUBNETWORK_CREATION. Possible values: ["DELEGATION", "EXTERNAL_IPV6_FORWARDING_RULE_CREATION", "EXTERNAL_IPV6_SUBNETWORK_CREATION"]`,
},
"project": {
Type: schema.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ func listAndActionComputePublicDelegatedPrefix(action sweeper.ResourceAction) er
t := &testing.T{}
billingId := envvar.GetTestBillingAccountFromEnv(t)
// Build URL substitution maps individually to ensure proper formatting
intermediateValues := make([]map[string]string, 2)
intermediateValues := make([]map[string]string, 3)
intermediateValues[0] = map[string]string{}
intermediateValues[0]["region"] = "us-central1"
intermediateValues[1] = map[string]string{}
intermediateValues[1]["region"] = "us-west1"
intermediateValues[2] = map[string]string{}
intermediateValues[2]["region"] = "us-east1"

// Create configs from intermediate values
for _, values := range intermediateValues {
Expand Down
34 changes: 32 additions & 2 deletions website/docs/r/compute_public_delegated_prefix.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ resource "google_compute_public_delegated_prefix" "subprefix" {
mode = "EXTERNAL_IPV6_FORWARDING_RULE_CREATION"
}
```
## Example Usage - Public Delegated Prefix Ipv6 Subnet Mode


```hcl
resource "google_compute_public_advertised_prefix" "advertised" {
name = "ipv6-pap"
description = "description"
dns_verification_ip = "2001:db8::"
ip_cidr_range = "2001:db8::/32"
pdp_scope = "REGIONAL"
}

resource "google_compute_public_delegated_prefix" "prefix" {
name = "ipv6-root-pdp"
description = "test-delegation-mode-pdp"
region = "us-east1"
ip_cidr_range = "2001:db8::/40"
parent_prefix = google_compute_public_advertised_prefix.advertised.id
mode = "DELEGATION"
}

resource "google_compute_public_delegated_prefix" "subprefix" {
name = "ipv6-sub-pdp"
description = "test-subnet-mode-pdp"
region = "us-east1"
ip_cidr_range = "2001:db8::/48"
parent_prefix = google_compute_public_delegated_prefix.prefix.id
mode = "EXTERNAL_IPV6_SUBNETWORK_CREATION"
}
```

## Argument Reference

Expand Down Expand Up @@ -122,8 +152,8 @@ The following arguments are supported:
* `mode` -
(Optional)
Specifies the mode of this IPv6 PDP. MODE must be one of: DELEGATION,
EXTERNAL_IPV6_FORWARDING_RULE_CREATION.
Possible values are: `DELEGATION`, `EXTERNAL_IPV6_FORWARDING_RULE_CREATION`.
EXTERNAL_IPV6_FORWARDING_RULE_CREATION and EXTERNAL_IPV6_SUBNETWORK_CREATION.
Possible values are: `DELEGATION`, `EXTERNAL_IPV6_FORWARDING_RULE_CREATION`, `EXTERNAL_IPV6_SUBNETWORK_CREATION`.

* `allocatable_prefix_length` -
(Optional)
Expand Down
Loading