@@ -492,6 +492,7 @@ func (c *Client) SetInstancePolicies(ctx context.Context, policies MultiplePolic
492
492
PolicyType : AllowedNetwork ,
493
493
PolicyData : PolicyData {
494
494
Enabled : & (policies .AllowedNetwork .Enabled ),
495
+ // due to legacy reasons, the allowed_network policy requires attribute to always be specified
495
496
Attributes : & Attributes {
496
497
AllowedNetwork : & (policies .AllowedNetwork .Network ),
497
498
},
@@ -505,11 +506,16 @@ func (c *Client) SetInstancePolicies(ctx context.Context, policies MultiplePolic
505
506
PolicyType : AllowedIP ,
506
507
PolicyData : PolicyData {
507
508
Enabled : & (policies .AllowedIP .Enabled ),
508
- Attributes : & Attributes {
509
- AllowedIP : policies .AllowedIP .IPAddresses ,
510
- },
511
509
},
512
510
}
511
+
512
+ // attributes can only be provided if policy is being enabled
513
+ // ignore any attribute inputs if provided during a disable
514
+ if policies .AllowedIP .Enabled {
515
+ policy .PolicyData .Attributes = & Attributes {
516
+ AllowedIP : policies .AllowedIP .IPAddresses ,
517
+ }
518
+ }
513
519
resPolicies = append (resPolicies , policy )
514
520
}
515
521
@@ -527,16 +533,21 @@ func (c *Client) SetInstancePolicies(ctx context.Context, policies MultiplePolic
527
533
policy := InstancePolicy {
528
534
PolicyType : KeyCreateImportAccess ,
529
535
PolicyData : PolicyData {
530
- Enabled : & (policies .KeyCreateImportAccess .Enabled ),
531
- Attributes : & Attributes {},
536
+ Enabled : & (policies .KeyCreateImportAccess .Enabled ),
532
537
},
533
538
}
534
539
535
- policy .PolicyData .Attributes .CreateRootKey = & policies .KeyCreateImportAccess .CreateRootKey
536
- policy .PolicyData .Attributes .CreateStandardKey = & policies .KeyCreateImportAccess .CreateStandardKey
537
- policy .PolicyData .Attributes .ImportRootKey = & policies .KeyCreateImportAccess .ImportRootKey
538
- policy .PolicyData .Attributes .ImportStandardKey = & policies .KeyCreateImportAccess .ImportStandardKey
539
- policy .PolicyData .Attributes .EnforceToken = & policies .KeyCreateImportAccess .EnforceToken
540
+ // attributes can only be provided if policy is being enabled
541
+ // ignore any attribute inputs if provided during a disable
542
+ if policies .KeyCreateImportAccess .Enabled {
543
+ policy .PolicyData .Attributes = & Attributes {
544
+ CreateRootKey : & policies .KeyCreateImportAccess .CreateRootKey ,
545
+ CreateStandardKey : & policies .KeyCreateImportAccess .CreateStandardKey ,
546
+ ImportRootKey : & policies .KeyCreateImportAccess .ImportRootKey ,
547
+ ImportStandardKey : & policies .KeyCreateImportAccess .ImportStandardKey ,
548
+ EnforceToken : & policies .KeyCreateImportAccess .EnforceToken ,
549
+ }
550
+ }
540
551
541
552
resPolicies = append (resPolicies , policy )
542
553
}
0 commit comments