@@ -22,6 +22,8 @@ import (
22
22
"log"
23
23
"net/http"
24
24
"reflect"
25
+ "slices"
26
+ "sort"
25
27
"strings"
26
28
"time"
27
29
@@ -32,6 +34,56 @@ import (
32
34
"github.com/hashicorp/terraform-provider-google/google/verify"
33
35
)
34
36
37
+ func AccessContextManagerServicePerimeterEgressToResourcesDiffSupressFunc (_ , _ , _ string , d * schema.ResourceData ) bool {
38
+ old , new := d .GetChange ("egress_to.0.resources" )
39
+
40
+ oldResources , err := tpgresource .InterfaceSliceToStringSlice (old )
41
+ if err != nil {
42
+ log .Printf ("[ERROR] Failed to convert config value: %s" , err )
43
+ return false
44
+ }
45
+
46
+ newResources , err := tpgresource .InterfaceSliceToStringSlice (new )
47
+ if err != nil {
48
+ log .Printf ("[ERROR] Failed to convert config value: %s" , err )
49
+ return false
50
+ }
51
+
52
+ sort .Strings (oldResources )
53
+ sort .Strings (newResources )
54
+
55
+ return slices .Equal (oldResources , newResources )
56
+ }
57
+
58
+ func AccessContextManagerServicePerimeterIngressToResourcesDiffSupressFunc (_ , _ , _ string , d * schema.ResourceData ) bool {
59
+ old , new := d .GetChange ("ingress_to.0.resources" )
60
+
61
+ oldResources , err := tpgresource .InterfaceSliceToStringSlice (old )
62
+ if err != nil {
63
+ log .Printf ("[ERROR] Failed to convert config value: %s" , err )
64
+ return false
65
+ }
66
+
67
+ newResources , err := tpgresource .InterfaceSliceToStringSlice (new )
68
+ if err != nil {
69
+ log .Printf ("[ERROR] Failed to convert config value: %s" , err )
70
+ return false
71
+ }
72
+
73
+ sort .Strings (oldResources )
74
+ sort .Strings (newResources )
75
+
76
+ return slices .Equal (oldResources , newResources )
77
+ }
78
+
79
+ func AccessContextManagerServicePerimeterIdentityTypeDiffSupressFunc (_ , old , new string , _ * schema.ResourceData ) bool {
80
+ if old == "" && new == "IDENTITY_TYPE_UNSPECIFIED" {
81
+ return true
82
+ }
83
+
84
+ return old == new
85
+ }
86
+
35
87
func ResourceAccessContextManagerServicePerimeter () * schema.Resource {
36
88
return & schema.Resource {
37
89
Create : resourceAccessContextManagerServicePerimeterCreate ,
@@ -156,9 +208,10 @@ represent individual user or service account only.`,
156
208
Set : schema .HashString ,
157
209
},
158
210
"identity_type" : {
159
- Type : schema .TypeString ,
160
- Optional : true ,
161
- ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
211
+ Type : schema .TypeString ,
212
+ Optional : true ,
213
+ ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
214
+ DiffSuppressFunc : AccessContextManagerServicePerimeterIdentityTypeDiffSupressFunc ,
162
215
Description : `Specifies the type of identities that are allowed access to outside the
163
216
perimeter. If left unspecified, then members of 'identities' field will
164
217
be allowed access. Possible values: ["IDENTITY_TYPE_UNSPECIFIED", "ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT"]` ,
@@ -295,9 +348,10 @@ individual user or service account only.`,
295
348
Set : schema .HashString ,
296
349
},
297
350
"identity_type" : {
298
- Type : schema .TypeString ,
299
- Optional : true ,
300
- ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
351
+ Type : schema .TypeString ,
352
+ Optional : true ,
353
+ ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
354
+ DiffSuppressFunc : AccessContextManagerServicePerimeterIdentityTypeDiffSupressFunc ,
301
355
Description : `Specifies the type of identities that are allowed access from outside the
302
356
perimeter. If left unspecified, then members of 'identities' field will be
303
357
allowed access. Possible values: ["IDENTITY_TYPE_UNSPECIFIED", "ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT"]` ,
@@ -520,9 +574,10 @@ represent individual user or service account only.`,
520
574
Set : schema .HashString ,
521
575
},
522
576
"identity_type" : {
523
- Type : schema .TypeString ,
524
- Optional : true ,
525
- ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
577
+ Type : schema .TypeString ,
578
+ Optional : true ,
579
+ ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
580
+ DiffSuppressFunc : AccessContextManagerServicePerimeterIdentityTypeDiffSupressFunc ,
526
581
Description : `Specifies the type of identities that are allowed access to outside the
527
582
perimeter. If left unspecified, then members of 'identities' field will
528
583
be allowed access. Possible values: ["IDENTITY_TYPE_UNSPECIFIED", "ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT"]` ,
@@ -659,9 +714,10 @@ individual user or service account only.`,
659
714
Set : schema .HashString ,
660
715
},
661
716
"identity_type" : {
662
- Type : schema .TypeString ,
663
- Optional : true ,
664
- ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
717
+ Type : schema .TypeString ,
718
+ Optional : true ,
719
+ ValidateFunc : verify .ValidateEnum ([]string {"IDENTITY_TYPE_UNSPECIFIED" , "ANY_IDENTITY" , "ANY_USER_ACCOUNT" , "ANY_SERVICE_ACCOUNT" , "" }),
720
+ DiffSuppressFunc : AccessContextManagerServicePerimeterIdentityTypeDiffSupressFunc ,
665
721
Description : `Specifies the type of identities that are allowed access from outside the
666
722
perimeter. If left unspecified, then members of 'identities' field will be
667
723
allowed access. Possible values: ["IDENTITY_TYPE_UNSPECIFIED", "ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT"]` ,
0 commit comments