@@ -31,6 +31,12 @@ const (
3131 IsFileShareReplicationRoleReplica = "replica"
3232)
3333
34+ func normalizeValue (value string ) string {
35+ if value == "user_managed" {
36+ return "ipsec"
37+ }
38+ return value
39+ }
3440func ResourceIbmIsShare () * schema.Resource {
3541 return & schema.Resource {
3642 CreateContext : resourceIbmIsShareCreate ,
@@ -54,10 +60,26 @@ func ResourceIbmIsShare() *schema.Resource {
5460
5561 Schema : map [string ]* schema.Schema {
5662 "allowed_transit_encryption_modes" : {
57- Type : schema .TypeList ,
58- Optional : true ,
59- Computed : true ,
60- Elem : & schema.Schema {Type : schema .TypeString },
63+ Type : schema .TypeSet ,
64+ Optional : true ,
65+ Computed : true ,
66+ Set : func (v interface {}) int {
67+ str := v .(string )
68+ normalized := normalizeValue (str )
69+ return schema .HashString (normalized )
70+ },
71+ Elem : & schema.Schema {
72+ Type : schema .TypeString ,
73+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
74+ if old == "user_managed" && new == "ipsec" {
75+ return true
76+ }
77+ if old == "ipsec" && new == "user_managed" {
78+ return true
79+ }
80+ return false
81+ },
82+ },
6183 Description : "Allowed transit encryption modes" ,
6284 },
6385 "allowed_access_protocols" : {
@@ -164,6 +186,15 @@ func ResourceIbmIsShare() *schema.Resource {
164186 Optional : true ,
165187 Computed : true ,
166188 Description : "The transit encryption mode." ,
189+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
190+ if old == "user_managed" && new == "ipsec" {
191+ return true
192+ }
193+ if old == "ipsec" && new == "user_managed" {
194+ return true
195+ }
196+ return false
197+ },
167198 },
168199 "name" : {
169200 Type : schema .TypeString ,
@@ -334,13 +365,6 @@ func ResourceIbmIsShare() *schema.Resource {
334365 Description : "Configuration for a replica file share to create and associate with this file share. Ifunspecified, a replica may be subsequently added by creating a new file share with a`source_share` referencing this file share." ,
335366 Elem : & schema.Resource {
336367 Schema : map [string ]* schema.Schema {
337- "allowed_transit_encryption_modes" : {
338- Type : schema .TypeList ,
339- Optional : true ,
340- Computed : true ,
341- Elem : & schema.Schema {Type : schema .TypeString },
342- Description : "Allowed transit encryption modes" ,
343- },
344368 "crn" : {
345369 Type : schema .TypeString ,
346370 Computed : true ,
@@ -447,6 +471,15 @@ func ResourceIbmIsShare() *schema.Resource {
447471 Optional : true ,
448472 Computed : true ,
449473 Description : "The transit encryption mode." ,
474+ DiffSuppressFunc : func (k , old , new string , d * schema.ResourceData ) bool {
475+ if old == "user_managed" && new == "ipsec" {
476+ return true
477+ }
478+ if old == "ipsec" && new == "user_managed" {
479+ return true
480+ }
481+ return false
482+ },
450483 },
451484 "virtual_network_interface" : {
452485 Type : schema .TypeList ,
@@ -1170,19 +1203,6 @@ func resourceIbmIsShareCreate(context context.Context, d *schema.ResourceData, m
11701203 replicaShareMap := replicaShareIntf .([]interface {})[0 ].(map [string ]interface {})
11711204 replicaShare := & vpcv1.SharePrototypeShareContext {}
11721205
1173- if allowedTEMIntf , ok := replicaShareMap ["allowed_transit_encryption_modes" ]; ok {
1174- allowedTransitEncryptionModes := []string {}
1175- allowedTransitEncryptionModesIntf := allowedTEMIntf .([]interface {})
1176- for _ , allowedTransitEncryptionModesItemIntf := range allowedTransitEncryptionModesIntf {
1177- allowedTransitEncryptionModesItem := allowedTransitEncryptionModesItemIntf .(string )
1178- if allowedTransitEncryptionModesItem == "user_managed" {
1179- allowedTransitEncryptionModesItem = "ipsec"
1180- }
1181- allowedTransitEncryptionModes = append (allowedTransitEncryptionModes , allowedTransitEncryptionModesItem )
1182- }
1183- replicaShare .AllowedTransitEncryptionModes = allowedTransitEncryptionModes
1184- }
1185-
11861206 iopsIntf , ok := replicaShareMap ["iops" ]
11871207 iops := iopsIntf .(int )
11881208 if ok && iops != 0 {
@@ -1461,10 +1481,12 @@ func resourceIbmIsShareRead(context context.Context, d *schema.ResourceData, met
14611481 return flex .DiscriminatedTerraformErrorf (err , err .Error (), "ibm_is_share" , "read" , "set-access_control_mode" ).GetDiag ()
14621482 }
14631483 }
1484+ allowedaccessprotocols := []string {}
14641485 if share .AllowedAccessProtocols != nil && len (share .AllowedAccessProtocols ) > 0 {
1465- if err = d .Set ("allowed_access_protocols" , * & share .AllowedAccessProtocols ); err != nil {
1466- return flex .DiscriminatedTerraformErrorf (err , err .Error (), "ibm_is_share" , "read" , "set-allowed_access_protocols" ).GetDiag ()
1467- }
1486+ allowedaccessprotocols = share .AllowedAccessProtocols
1487+ }
1488+ if err = d .Set ("allowed_access_protocols" , allowedaccessprotocols ); err != nil {
1489+ return flex .DiscriminatedTerraformErrorf (err , err .Error (), "ibm_is_share" , "read" , "set-allowed_access_protocols" ).GetDiag ()
14681490 }
14691491 if err = d .Set ("bandwidth" , flex .IntValue (share .Bandwidth )); err != nil {
14701492 return diag .FromErr (fmt .Errorf ("Error setting bandwidth: %s" , err ))
0 commit comments