@@ -262,23 +262,30 @@ func createSO(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
262
262
}
263
263
security_object ["rsa" ] = rsa_obj
264
264
}
265
- allowed_key_justifications_policy := d .Get ("allowed_key_justifications_policy" )
266
- allowed_missing_justifications := d .Get ("allowed_missing_justifications" )
267
-
268
- if allowed_key_justifications_policy != nil && allowed_missing_justifications != nil {
269
- security_object ["google_access_reason_policy" ] = map [string ]interface {}{
270
- "allow" : allowed_key_justifications_policy ,
271
- "allow_missing_reason" : allowed_missing_justifications ,
265
+ allowed_key_justifications_policy , ok := d .GetOk ("allowed_key_justifications_policy" )
266
+ allowed_missing_justifications , ok2 := d .GetOkExists ("allowed_missing_justifications" )
267
+
268
+ if ok && ok2 {
269
+ if allowed_key_justifications_policy != nil && allowed_missing_justifications != nil {
270
+ security_object ["google_access_reason_policy" ] = map [string ]interface {}{
271
+ "allow" : allowed_key_justifications_policy ,
272
+ "allow_missing_reason" : allowed_missing_justifications ,
273
+ }
272
274
}
273
- } else if allowed_key_justifications_policy != nil {
274
- security_object ["google_access_reason_policy" ] = map [string ]interface {}{
275
- "allow" : allowed_key_justifications_policy ,
275
+ } else if ok {
276
+ if allowed_key_justifications_policy != nil {
277
+ security_object ["google_access_reason_policy" ] = map [string ]interface {}{
278
+ "allow" : allowed_key_justifications_policy ,
279
+ }
276
280
}
277
- } else if allowed_missing_justifications != nil {
278
- security_object ["google_access_reason_policy" ] = map [string ]interface {}{
279
- "allow_missing_reason" : allowed_missing_justifications ,
281
+ } else if ok2 {
282
+ if allowed_missing_justifications != nil {
283
+ security_object ["google_access_reason_policy" ] = map [string ]interface {}{
284
+ "allow_missing_reason" : allowed_missing_justifications ,
285
+ }
280
286
}
281
287
}
288
+
282
289
if err := d .Get ("fpe_radix" ); err != 0 {
283
290
security_object ["fpe" ] = map [string ]interface {}{
284
291
"radix" : d .Get ("fpe_radix" ).(int ),
@@ -532,7 +539,6 @@ func resourceUpdateSobject(ctx context.Context, d *schema.ResourceData, m interf
532
539
security_object ["rsa" ] = rsa_obj
533
540
has_changed = true
534
541
}
535
-
536
542
if d .HasChanges ("allowed_key_justifications_policy" , "allowed_missing_justifications" ) {
537
543
538
544
google_access_reason_policy := make (map [string ]interface {})
@@ -544,7 +550,6 @@ func resourceUpdateSobject(ctx context.Context, d *schema.ResourceData, m interf
544
550
545
551
security_object ["google_access_reason_policy" ] = google_access_reason_policy
546
552
}
547
-
548
553
if d .HasChange ("key_ops" ) {
549
554
security_object ["key_ops" ] = d .Get ("key_ops" )
550
555
has_changed = true
0 commit comments