Skip to content

Commit 67d5c01

Browse files
Adding IPv6 Access Type to PAP (#15548) (#10978)
[upstream:4c714596c404ecc8e04f49dc310db18277fe0eab] Signed-off-by: Modular Magician <[email protected]>
1 parent 18bdc88 commit 67d5c01

File tree

5 files changed

+110
-17
lines changed

5 files changed

+110
-17
lines changed

.changelog/15548.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `ipv6_access_type` field to `google_compute_public_advertised_prefix` resource
3+
```

google-beta/services/compute/resource_compute_public_advertised_prefix.go

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ func ResourceComputePublicAdvertisedPrefix() *schema.Resource {
5454
),
5555

5656
Schema: map[string]*schema.Schema{
57-
"dns_verification_ip": {
58-
Type: schema.TypeString,
59-
Required: true,
60-
ForceNew: true,
61-
Description: `The IPv4 address to be used for reverse DNS verification.`,
62-
},
6357
"ip_cidr_range": {
6458
Type: schema.TypeString,
6559
Required: true,
@@ -83,6 +77,26 @@ except the last character, which cannot be a dash.`,
8377
ForceNew: true,
8478
Description: `An optional description of this resource.`,
8579
},
80+
"dns_verification_ip": {
81+
Type: schema.TypeString,
82+
Optional: true,
83+
ForceNew: true,
84+
Description: `The IPv4 address to be used for reverse DNS verification.`,
85+
},
86+
"ipv6_access_type": {
87+
Type: schema.TypeString,
88+
Computed: true,
89+
Optional: true,
90+
ForceNew: true,
91+
ValidateFunc: verify.ValidateEnum([]string{"EXTERNAL", "INTERNAL", ""}),
92+
Description: `The internet access type for IPv6 Public Advertised Prefixes. It can be
93+
set to one of following:
94+
* EXTERNAL: Default access type. The prefix will be announced to the
95+
internet. All children PDPs will have access type as EXTERNAL.
96+
* INTERNAL: The prefix won’t be announced to the internet. Prefix will
97+
be used privately within Google Cloud. All children PDPs will have
98+
access type as INTERNAL. Possible values: ["EXTERNAL", "INTERNAL"]`,
99+
},
86100
"pdp_scope": {
87101
Type: schema.TypeString,
88102
Optional: true,
@@ -153,6 +167,12 @@ func resourceComputePublicAdvertisedPrefixCreate(d *schema.ResourceData, meta in
153167
} else if v, ok := d.GetOkExists("pdp_scope"); !tpgresource.IsEmptyValue(reflect.ValueOf(pdpScopeProp)) && (ok || !reflect.DeepEqual(v, pdpScopeProp)) {
154168
obj["pdpScope"] = pdpScopeProp
155169
}
170+
ipv6AccessTypeProp, err := expandComputePublicAdvertisedPrefixIpv6AccessType(d.Get("ipv6_access_type"), d, config)
171+
if err != nil {
172+
return err
173+
} else if v, ok := d.GetOkExists("ipv6_access_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipv6AccessTypeProp)) && (ok || !reflect.DeepEqual(v, ipv6AccessTypeProp)) {
174+
obj["ipv6AccessType"] = ipv6AccessTypeProp
175+
}
156176

157177
url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/publicAdvertisedPrefixes")
158178
if err != nil {
@@ -267,6 +287,9 @@ func resourceComputePublicAdvertisedPrefixRead(d *schema.ResourceData, meta inte
267287
if err := d.Set("pdp_scope", flattenComputePublicAdvertisedPrefixPdpScope(res["pdpScope"], d, config)); err != nil {
268288
return fmt.Errorf("Error reading PublicAdvertisedPrefix: %s", err)
269289
}
290+
if err := d.Set("ipv6_access_type", flattenComputePublicAdvertisedPrefixIpv6AccessType(res["ipv6AccessType"], d, config)); err != nil {
291+
return fmt.Errorf("Error reading PublicAdvertisedPrefix: %s", err)
292+
}
270293
if err := d.Set("shared_secret", flattenComputePublicAdvertisedPrefixSharedSecret(res["sharedSecret"], d, config)); err != nil {
271294
return fmt.Errorf("Error reading PublicAdvertisedPrefix: %s", err)
272295
}
@@ -373,6 +396,10 @@ func flattenComputePublicAdvertisedPrefixPdpScope(v interface{}, d *schema.Resou
373396
return v
374397
}
375398

399+
func flattenComputePublicAdvertisedPrefixIpv6AccessType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
400+
return v
401+
}
402+
376403
func flattenComputePublicAdvertisedPrefixSharedSecret(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
377404
return v
378405
}
@@ -396,3 +423,7 @@ func expandComputePublicAdvertisedPrefixIpCidrRange(v interface{}, d tpgresource
396423
func expandComputePublicAdvertisedPrefixPdpScope(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
397424
return v, nil
398425
}
426+
427+
func expandComputePublicAdvertisedPrefixIpv6AccessType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
428+
return v, nil
429+
}

google-beta/services/compute/resource_compute_public_advertised_prefix_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fields:
88
- api_field: 'description'
99
- api_field: 'dnsVerificationIp'
1010
- api_field: 'ipCidrRange'
11+
- api_field: 'ipv6AccessType'
1112
- api_field: 'name'
1213
- api_field: 'pdpScope'
1314
- api_field: 'sharedSecret'

google-beta/services/compute/resource_compute_public_advertised_prefix_test.go

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ import (
3232
// Since we only have access to one test prefix range we cannot run tests in parallel
3333
func TestAccComputePublicPrefixes(t *testing.T) {
3434
testCases := map[string]func(t *testing.T){
35-
"delegated_prefix": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesBasicTest,
36-
"advertised_prefix": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest,
37-
"public_delegated_prefixes_ipv6": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesIpv6Test,
38-
"public_advertised_prefixes_pdp_scope": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeTest,
39-
"public_delegated_prefix_ipv6_subnet_mode": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixIpv6SubnetModeTest,
40-
"public_delgated_prefix_with_sub_prefix": TestAccComputePublicDelegatedPrefix_computePublicDelegatedPrefixWithSubPrefixExample,
35+
"delegated_prefix": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesBasicTest,
36+
"advertised_prefix": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesBasicTest,
37+
"public_delegated_prefixes_ipv6": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixesIpv6Test,
38+
"public_advertised_prefixes_pdp_scope": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesPdpScopeTest,
39+
"public_delegated_prefix_ipv6_subnet_mode": testAccComputePublicDelegatedPrefix_publicDelegatedPrefixIpv6SubnetModeTest,
40+
"public_delgated_prefix_with_sub_prefix": TestAccComputePublicDelegatedPrefix_computePublicDelegatedPrefixWithSubPrefixExample,
41+
"public_advertised_prefixes_internal_ipv6_access": testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesInternalIpv6AccessTest,
4142
}
4243

4344
for name, tc := range testCases {
@@ -52,8 +53,42 @@ func TestAccComputePublicPrefixes(t *testing.T) {
5253
}
5354
}
5455

56+
func testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesInternalIpv6AccessTest(t *testing.T) {
57+
context := map[string]interface{}{
58+
"description": envvar.GetTestPublicAdvertisedPrefixDescriptionFromEnv(t),
59+
"random_suffix": acctest.RandString(t, 10),
60+
}
61+
62+
acctest.VcrTest(t, resource.TestCase{
63+
PreCheck: func() { acctest.AccTestPreCheck(t) },
64+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
65+
CheckDestroy: testAccCheckComputePublicAdvertisedPrefixDestroyProducer(t),
66+
Steps: []resource.TestStep{
67+
{
68+
Config: testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesInternalIpv6AccessExample(context),
69+
},
70+
{
71+
ResourceName: "google_compute_public_advertised_prefix.prefix",
72+
ImportState: true,
73+
ImportStateVerify: true,
74+
},
75+
},
76+
})
77+
}
78+
79+
func testAccComputePublicAdvertisedPrefix_publicAdvertisedPrefixesInternalIpv6AccessExample(context map[string]interface{}) string {
80+
return acctest.Nprintf(`
81+
resource "google_compute_public_advertised_prefix" "prefix" {
82+
name = "tf-test-my-prefix%{random_suffix}"
83+
description = "%{description}"
84+
ip_cidr_range = "2001:db8::/32"
85+
pdp_scope = "REGIONAL"
86+
ipv6_access_type = "INTERNAL"
87+
}
88+
`, context)
89+
}
90+
5591
func TestAccComputePublicDelegatedPrefix_computePublicDelegatedPrefixWithSubPrefixExample(t *testing.T) {
56-
t.Parallel()
5792
subPrefixResourceName := "google_compute_public_delegated_prefix.subprefix"
5893
parentProject := "tf-static-byoip"
5994
parentRegion := "us-central1"

website/docs/r/compute_public_advertised_prefix.html.markdown

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ resource "google_compute_public_advertised_prefix" "prefixes" {
5353
pdp_scope = "REGIONAL"
5454
}
5555
```
56+
## Example Usage - Public Advertised Prefixes Ipv6 Access Type
57+
58+
59+
```hcl
60+
resource "google_compute_public_advertised_prefix" "prefixes" {
61+
name = "my-pap"
62+
description = "description"
63+
ip_cidr_range = "2001:db8::/32"
64+
pdp_scope = "REGIONAL"
65+
ipv6_access_type = "INTERNAL"
66+
}
67+
```
5668

5769
## Argument Reference
5870

@@ -68,10 +80,6 @@ The following arguments are supported:
6880
following characters must be a dash, lowercase letter, or digit,
6981
except the last character, which cannot be a dash.
7082

71-
* `dns_verification_ip` -
72-
(Required)
73-
The IPv4 address to be used for reverse DNS verification.
74-
7583
* `ip_cidr_range` -
7684
(Required)
7785
The address range, in CIDR format, represented by this public advertised prefix.
@@ -81,6 +89,10 @@ The following arguments are supported:
8189
(Optional)
8290
An optional description of this resource.
8391

92+
* `dns_verification_ip` -
93+
(Optional)
94+
The IPv4 address to be used for reverse DNS verification.
95+
8496
* `pdp_scope` -
8597
(Optional)
8698
Specifies how child public delegated prefix will be scoped. pdpScope
@@ -91,6 +103,17 @@ The following arguments are supported:
91103
will take ~4 weeks.
92104
Possible values are: `GLOBAL`, `REGIONAL`.
93105

106+
* `ipv6_access_type` -
107+
(Optional)
108+
The internet access type for IPv6 Public Advertised Prefixes. It can be
109+
set to one of following:
110+
* EXTERNAL: Default access type. The prefix will be announced to the
111+
internet. All children PDPs will have access type as EXTERNAL.
112+
* INTERNAL: The prefix won’t be announced to the internet. Prefix will
113+
be used privately within Google Cloud. All children PDPs will have
114+
access type as INTERNAL.
115+
Possible values are: `EXTERNAL`, `INTERNAL`.
116+
94117
* `project` - (Optional) The ID of the project in which the resource belongs.
95118
If it is not provided, the provider project is used.
96119

0 commit comments

Comments
 (0)