@@ -30,6 +30,7 @@ import (
30
30
31
31
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
32
32
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
33
+ "github.com/hashicorp/terraform-provider-google-beta/google-beta/verify"
33
34
)
34
35
35
36
func ResourceBackupDRBackupVault () * schema.Resource {
@@ -73,6 +74,14 @@ func ResourceBackupDRBackupVault() *schema.Resource {
73
74
ForceNew : true ,
74
75
Description : `The GCP location for the backup vault.` ,
75
76
},
77
+ "access_restriction" : {
78
+ Type : schema .TypeString ,
79
+ Optional : true ,
80
+ ForceNew : true ,
81
+ ValidateFunc : verify .ValidateEnum ([]string {"ACCESS_RESTRICTION_UNSPECIFIED" , "WITHIN_PROJECT" , "WITHIN_ORGANIZATION" , "UNRESTRICTED" , "WITHIN_ORG_BUT_UNRESTRICTED_FOR_BA" , "" }),
82
+ Description : `Access restriction for the backup vault. Default value is 'WITHIN_ORGANIZATION' if not provided during creation. Default value: "WITHIN_ORGANIZATION" Possible values: ["ACCESS_RESTRICTION_UNSPECIFIED", "WITHIN_PROJECT", "WITHIN_ORGANIZATION", "UNRESTRICTED", "WITHIN_ORG_BUT_UNRESTRICTED_FOR_BA"]` ,
83
+ Default : "WITHIN_ORGANIZATION" ,
84
+ },
76
85
"allow_missing" : {
77
86
Type : schema .TypeBool ,
78
87
Optional : true ,
@@ -254,6 +263,12 @@ func resourceBackupDRBackupVaultCreate(d *schema.ResourceData, meta interface{})
254
263
} else if v , ok := d .GetOkExists ("effective_time" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (effectiveTimeProp )) && (ok || ! reflect .DeepEqual (v , effectiveTimeProp )) {
255
264
obj ["effectiveTime" ] = effectiveTimeProp
256
265
}
266
+ accessRestrictionProp , err := expandBackupDRBackupVaultAccessRestriction (d .Get ("access_restriction" ), d , config )
267
+ if err != nil {
268
+ return err
269
+ } else if v , ok := d .GetOkExists ("access_restriction" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (accessRestrictionProp )) && (ok || ! reflect .DeepEqual (v , accessRestrictionProp )) {
270
+ obj ["accessRestriction" ] = accessRestrictionProp
271
+ }
257
272
labelsProp , err := expandBackupDRBackupVaultEffectiveLabels (d .Get ("effective_labels" ), d , config )
258
273
if err != nil {
259
274
return err
@@ -424,6 +439,9 @@ func resourceBackupDRBackupVaultRead(d *schema.ResourceData, meta interface{}) e
424
439
if err := d .Set ("annotations" , flattenBackupDRBackupVaultAnnotations (res ["annotations" ], d , config )); err != nil {
425
440
return fmt .Errorf ("Error reading BackupVault: %s" , err )
426
441
}
442
+ if err := d .Set ("access_restriction" , flattenBackupDRBackupVaultAccessRestriction (res ["accessRestriction" ], d , config )); err != nil {
443
+ return fmt .Errorf ("Error reading BackupVault: %s" , err )
444
+ }
427
445
if err := d .Set ("terraform_labels" , flattenBackupDRBackupVaultTerraformLabels (res ["labels" ], d , config )); err != nil {
428
446
return fmt .Errorf ("Error reading BackupVault: %s" , err )
429
447
}
@@ -737,6 +755,10 @@ func flattenBackupDRBackupVaultAnnotations(v interface{}, d *schema.ResourceData
737
755
return transformed
738
756
}
739
757
758
+ func flattenBackupDRBackupVaultAccessRestriction (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
759
+ return v
760
+ }
761
+
740
762
func flattenBackupDRBackupVaultTerraformLabels (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
741
763
if v == nil {
742
764
return v
@@ -772,6 +794,10 @@ func expandBackupDRBackupVaultEffectiveTime(v interface{}, d tpgresource.Terrafo
772
794
return v , nil
773
795
}
774
796
797
+ func expandBackupDRBackupVaultAccessRestriction (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
798
+ return v , nil
799
+ }
800
+
775
801
func expandBackupDRBackupVaultEffectiveLabels (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (map [string ]string , error ) {
776
802
if v == nil {
777
803
return map [string ]string {}, nil
0 commit comments