@@ -22,6 +22,8 @@ import (
2222 "log"
2323 "net/http"
2424 "reflect"
25+ "slices"
26+ "sort"
2527 "strings"
2628 "time"
2729
@@ -32,6 +34,56 @@ import (
3234 "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify"
3335)
3436
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+
3587func ResourceAccessContextManagerServicePerimeter () * schema.Resource {
3688 return & schema.Resource {
3789 Create : resourceAccessContextManagerServicePerimeterCreate ,
@@ -156,9 +208,10 @@ represent individual user or service account only.`,
156208 Set : schema .HashString ,
157209 },
158210 "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 ,
162215 Description : `Specifies the type of identities that are allowed access to outside the
163216perimeter. If left unspecified, then members of 'identities' field will
164217be 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.`,
295348 Set : schema .HashString ,
296349 },
297350 "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 ,
301355 Description : `Specifies the type of identities that are allowed access from outside the
302356perimeter. If left unspecified, then members of 'identities' field will be
303357allowed 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.`,
520574 Set : schema .HashString ,
521575 },
522576 "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 ,
526581 Description : `Specifies the type of identities that are allowed access to outside the
527582perimeter. If left unspecified, then members of 'identities' field will
528583be 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.`,
659714 Set : schema .HashString ,
660715 },
661716 "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 ,
665721 Description : `Specifies the type of identities that are allowed access from outside the
666722perimeter. If left unspecified, then members of 'identities' field will be
667723allowed access. Possible values: ["IDENTITY_TYPE_UNSPECIFIED", "ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT"]` ,
0 commit comments