@@ -73,6 +73,56 @@ for the standard tier, or 2560 GiB for the premium tier.`,
73
73
ForceNew : true ,
74
74
Description : `The name of the fileshare (16 characters or less)` ,
75
75
},
76
+ "nfs_export_options" : {
77
+ Type : schema .TypeList ,
78
+ Optional : true ,
79
+ Description : `Nfs Export Options. There is a limit of 10 export options per file share.` ,
80
+ MaxItems : 10 ,
81
+ Elem : & schema.Resource {
82
+ Schema : map [string ]* schema.Schema {
83
+ "access_mode" : {
84
+ Type : schema .TypeString ,
85
+ Optional : true ,
86
+ ValidateFunc : validateEnum ([]string {"READ_ONLY" , "READ_WRITE" , "" }),
87
+ Description : `Either READ_ONLY, for allowing only read requests on the exported directory,
88
+ or READ_WRITE, for allowing both read and write requests. The default is READ_WRITE. Default value: "READ_WRITE" Possible values: ["READ_ONLY", "READ_WRITE"]` ,
89
+ Default : "READ_WRITE" ,
90
+ },
91
+ "anon_gid" : {
92
+ Type : schema .TypeInt ,
93
+ Optional : true ,
94
+ Description : `An integer representing the anonymous group id with a default value of 65534.
95
+ Anon_gid may only be set with squashMode of ROOT_SQUASH. An error will be returned
96
+ if this field is specified for other squashMode settings.` ,
97
+ },
98
+ "anon_uid" : {
99
+ Type : schema .TypeInt ,
100
+ Optional : true ,
101
+ Description : `An integer representing the anonymous user id with a default value of 65534.
102
+ Anon_uid may only be set with squashMode of ROOT_SQUASH. An error will be returned
103
+ if this field is specified for other squashMode settings.` ,
104
+ },
105
+ "ip_ranges" : {
106
+ Type : schema .TypeList ,
107
+ Optional : true ,
108
+ Description : `List of either IPv4 addresses, or ranges in CIDR notation which may mount the file share.
109
+ Overlapping IP ranges are not allowed, both within and across NfsExportOptions. An error will be returned.
110
+ The limit is 64 IP ranges/addresses for each FileShareConfig among all NfsExportOptions.` ,
111
+ Elem : & schema.Schema {
112
+ Type : schema .TypeString ,
113
+ },
114
+ },
115
+ "squash_mode" : {
116
+ Type : schema .TypeString ,
117
+ Optional : true ,
118
+ ValidateFunc : validateEnum ([]string {"NO_ROOT_SQUASH" , "ROOT_SQUASH" , "" }),
119
+ Description : `Either NO_ROOT_SQUASH, for allowing root access on the exported directory, or ROOT_SQUASH,
120
+ for not allowing root access. The default is NO_ROOT_SQUASH. Default value: "NO_ROOT_SQUASH" Possible values: ["NO_ROOT_SQUASH", "ROOT_SQUASH"]` ,
121
+ Default : "NO_ROOT_SQUASH" ,
122
+ },
123
+ },
124
+ },
125
+ },
76
126
},
77
127
},
78
128
},
@@ -108,6 +158,16 @@ IP addresses assigned. Possible values: ["ADDRESS_MODE_UNSPECIFIED", "MODE_IPV4"
108
158
Description : `The name of the GCE VPC network to which the
109
159
instance is connected.` ,
110
160
},
161
+ "connect_mode" : {
162
+ Type : schema .TypeString ,
163
+ Optional : true ,
164
+ ForceNew : true ,
165
+ ValidateFunc : validateEnum ([]string {"DIRECT_PEERING" , "PRIVATE_SERVICE_ACCESS" , "" }),
166
+ Description : `The network connect mode of the Filestore instance.
167
+ If not provided, the connect mode defaults to
168
+ DIRECT_PEERING. Default value: "DIRECT_PEERING" Possible values: ["DIRECT_PEERING", "PRIVATE_SERVICE_ACCESS"]` ,
169
+ Default : "DIRECT_PEERING" ,
170
+ },
111
171
"reserved_ip_range" : {
112
172
Type : schema .TypeString ,
113
173
Computed : true ,
@@ -132,13 +192,19 @@ addresses reserved for this instance.`,
132
192
Required : true ,
133
193
ForceNew : true ,
134
194
Description : `The service tier of the instance.
135
- Possible values include: STANDARD, PREMIUM, BASIC_HDD, BASIC_SSD, HIGH_SCALE_SSD and ENTERPRISE (beta only) ` ,
195
+ Possible values include: STANDARD, PREMIUM, BASIC_HDD, BASIC_SSD, HIGH_SCALE_SSD and ENTERPRISE` ,
136
196
},
137
197
"description" : {
138
198
Type : schema .TypeString ,
139
199
Optional : true ,
140
200
Description : `A description of the instance.` ,
141
201
},
202
+ "kms_key_name" : {
203
+ Type : schema .TypeString ,
204
+ Optional : true ,
205
+ ForceNew : true ,
206
+ Description : `KMS key name used for data encryption.` ,
207
+ },
142
208
"labels" : {
143
209
Type : schema .TypeMap ,
144
210
Optional : true ,
@@ -222,6 +288,12 @@ func resourceFilestoreInstanceCreate(d *schema.ResourceData, meta interface{}) e
222
288
} else if v , ok := d .GetOkExists ("networks" ); ! isEmptyValue (reflect .ValueOf (networksProp )) && (ok || ! reflect .DeepEqual (v , networksProp )) {
223
289
obj ["networks" ] = networksProp
224
290
}
291
+ kmsKeyNameProp , err := expandFilestoreInstanceKmsKeyName (d .Get ("kms_key_name" ), d , config )
292
+ if err != nil {
293
+ return err
294
+ } else if v , ok := d .GetOkExists ("kms_key_name" ); ! isEmptyValue (reflect .ValueOf (kmsKeyNameProp )) && (ok || ! reflect .DeepEqual (v , kmsKeyNameProp )) {
295
+ obj ["kmsKeyName" ] = kmsKeyNameProp
296
+ }
225
297
226
298
lockName , err := replaceVars (d , config , "filestore/{{project}}" )
227
299
if err != nil {
@@ -357,6 +429,9 @@ func resourceFilestoreInstanceRead(d *schema.ResourceData, meta interface{}) err
357
429
if err := d .Set ("etag" , flattenFilestoreInstanceEtag (res ["etag" ], d , config )); err != nil {
358
430
return fmt .Errorf ("Error reading Instance: %s" , err )
359
431
}
432
+ if err := d .Set ("kms_key_name" , flattenFilestoreInstanceKmsKeyName (res ["kmsKeyName" ], d , config )); err != nil {
433
+ return fmt .Errorf ("Error reading Instance: %s" , err )
434
+ }
360
435
361
436
return nil
362
437
}
@@ -554,8 +629,9 @@ func flattenFilestoreInstanceFileShares(v interface{}, d *schema.ResourceData, c
554
629
continue
555
630
}
556
631
transformed = append (transformed , map [string ]interface {}{
557
- "name" : flattenFilestoreInstanceFileSharesName (original ["name" ], d , config ),
558
- "capacity_gb" : flattenFilestoreInstanceFileSharesCapacityGb (original ["capacityGb" ], d , config ),
632
+ "name" : flattenFilestoreInstanceFileSharesName (original ["name" ], d , config ),
633
+ "capacity_gb" : flattenFilestoreInstanceFileSharesCapacityGb (original ["capacityGb" ], d , config ),
634
+ "nfs_export_options" : flattenFilestoreInstanceFileSharesNfsExportOptions (original ["nfsExportOptions" ], d , config ),
559
635
})
560
636
}
561
637
return transformed
@@ -581,6 +657,74 @@ func flattenFilestoreInstanceFileSharesCapacityGb(v interface{}, d *schema.Resou
581
657
return v // let terraform core handle it otherwise
582
658
}
583
659
660
+ func flattenFilestoreInstanceFileSharesNfsExportOptions (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
661
+ if v == nil {
662
+ return v
663
+ }
664
+ l := v .([]interface {})
665
+ transformed := make ([]interface {}, 0 , len (l ))
666
+ for _ , raw := range l {
667
+ original := raw .(map [string ]interface {})
668
+ if len (original ) < 1 {
669
+ // Do not include empty json objects coming back from the api
670
+ continue
671
+ }
672
+ transformed = append (transformed , map [string ]interface {}{
673
+ "ip_ranges" : flattenFilestoreInstanceFileSharesNfsExportOptionsIpRanges (original ["ipRanges" ], d , config ),
674
+ "access_mode" : flattenFilestoreInstanceFileSharesNfsExportOptionsAccessMode (original ["accessMode" ], d , config ),
675
+ "squash_mode" : flattenFilestoreInstanceFileSharesNfsExportOptionsSquashMode (original ["squashMode" ], d , config ),
676
+ "anon_uid" : flattenFilestoreInstanceFileSharesNfsExportOptionsAnonUid (original ["anonUid" ], d , config ),
677
+ "anon_gid" : flattenFilestoreInstanceFileSharesNfsExportOptionsAnonGid (original ["anonGid" ], d , config ),
678
+ })
679
+ }
680
+ return transformed
681
+ }
682
+ func flattenFilestoreInstanceFileSharesNfsExportOptionsIpRanges (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
683
+ return v
684
+ }
685
+
686
+ func flattenFilestoreInstanceFileSharesNfsExportOptionsAccessMode (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
687
+ return v
688
+ }
689
+
690
+ func flattenFilestoreInstanceFileSharesNfsExportOptionsSquashMode (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
691
+ return v
692
+ }
693
+
694
+ func flattenFilestoreInstanceFileSharesNfsExportOptionsAnonUid (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
695
+ // Handles the string fixed64 format
696
+ if strVal , ok := v .(string ); ok {
697
+ if intVal , err := stringToFixed64 (strVal ); err == nil {
698
+ return intVal
699
+ }
700
+ }
701
+
702
+ // number values are represented as float64
703
+ if floatVal , ok := v .(float64 ); ok {
704
+ intVal := int (floatVal )
705
+ return intVal
706
+ }
707
+
708
+ return v // let terraform core handle it otherwise
709
+ }
710
+
711
+ func flattenFilestoreInstanceFileSharesNfsExportOptionsAnonGid (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
712
+ // Handles the string fixed64 format
713
+ if strVal , ok := v .(string ); ok {
714
+ if intVal , err := stringToFixed64 (strVal ); err == nil {
715
+ return intVal
716
+ }
717
+ }
718
+
719
+ // number values are represented as float64
720
+ if floatVal , ok := v .(float64 ); ok {
721
+ intVal := int (floatVal )
722
+ return intVal
723
+ }
724
+
725
+ return v // let terraform core handle it otherwise
726
+ }
727
+
584
728
func flattenFilestoreInstanceNetworks (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
585
729
if v == nil {
586
730
return v
@@ -598,6 +742,7 @@ func flattenFilestoreInstanceNetworks(v interface{}, d *schema.ResourceData, con
598
742
"modes" : flattenFilestoreInstanceNetworksModes (original ["modes" ], d , config ),
599
743
"reserved_ip_range" : flattenFilestoreInstanceNetworksReservedIpRange (original ["reservedIpRange" ], d , config ),
600
744
"ip_addresses" : flattenFilestoreInstanceNetworksIpAddresses (original ["ipAddresses" ], d , config ),
745
+ "connect_mode" : flattenFilestoreInstanceNetworksConnectMode (original ["connectMode" ], d , config ),
601
746
})
602
747
}
603
748
return transformed
@@ -618,10 +763,22 @@ func flattenFilestoreInstanceNetworksIpAddresses(v interface{}, d *schema.Resour
618
763
return v
619
764
}
620
765
766
+ func flattenFilestoreInstanceNetworksConnectMode (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
767
+ if v == nil || isEmptyValue (reflect .ValueOf (v )) {
768
+ return "DIRECT_PEERING"
769
+ }
770
+
771
+ return v
772
+ }
773
+
621
774
func flattenFilestoreInstanceEtag (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
622
775
return v
623
776
}
624
777
778
+ func flattenFilestoreInstanceKmsKeyName (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
779
+ return v
780
+ }
781
+
625
782
func expandFilestoreInstanceDescription (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
626
783
return v , nil
627
784
}
@@ -665,6 +822,13 @@ func expandFilestoreInstanceFileShares(v interface{}, d TerraformResourceData, c
665
822
transformed ["capacityGb" ] = transformedCapacityGb
666
823
}
667
824
825
+ transformedNfsExportOptions , err := expandFilestoreInstanceFileSharesNfsExportOptions (original ["nfs_export_options" ], d , config )
826
+ if err != nil {
827
+ return nil , err
828
+ } else if val := reflect .ValueOf (transformedNfsExportOptions ); val .IsValid () && ! isEmptyValue (val ) {
829
+ transformed ["nfsExportOptions" ] = transformedNfsExportOptions
830
+ }
831
+
668
832
req = append (req , transformed )
669
833
}
670
834
return req , nil
@@ -678,6 +842,76 @@ func expandFilestoreInstanceFileSharesCapacityGb(v interface{}, d TerraformResou
678
842
return v , nil
679
843
}
680
844
845
+ func expandFilestoreInstanceFileSharesNfsExportOptions (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
846
+ l := v .([]interface {})
847
+ req := make ([]interface {}, 0 , len (l ))
848
+ for _ , raw := range l {
849
+ if raw == nil {
850
+ continue
851
+ }
852
+ original := raw .(map [string ]interface {})
853
+ transformed := make (map [string ]interface {})
854
+
855
+ transformedIpRanges , err := expandFilestoreInstanceFileSharesNfsExportOptionsIpRanges (original ["ip_ranges" ], d , config )
856
+ if err != nil {
857
+ return nil , err
858
+ } else if val := reflect .ValueOf (transformedIpRanges ); val .IsValid () && ! isEmptyValue (val ) {
859
+ transformed ["ipRanges" ] = transformedIpRanges
860
+ }
861
+
862
+ transformedAccessMode , err := expandFilestoreInstanceFileSharesNfsExportOptionsAccessMode (original ["access_mode" ], d , config )
863
+ if err != nil {
864
+ return nil , err
865
+ } else if val := reflect .ValueOf (transformedAccessMode ); val .IsValid () && ! isEmptyValue (val ) {
866
+ transformed ["accessMode" ] = transformedAccessMode
867
+ }
868
+
869
+ transformedSquashMode , err := expandFilestoreInstanceFileSharesNfsExportOptionsSquashMode (original ["squash_mode" ], d , config )
870
+ if err != nil {
871
+ return nil , err
872
+ } else if val := reflect .ValueOf (transformedSquashMode ); val .IsValid () && ! isEmptyValue (val ) {
873
+ transformed ["squashMode" ] = transformedSquashMode
874
+ }
875
+
876
+ transformedAnonUid , err := expandFilestoreInstanceFileSharesNfsExportOptionsAnonUid (original ["anon_uid" ], d , config )
877
+ if err != nil {
878
+ return nil , err
879
+ } else if val := reflect .ValueOf (transformedAnonUid ); val .IsValid () && ! isEmptyValue (val ) {
880
+ transformed ["anonUid" ] = transformedAnonUid
881
+ }
882
+
883
+ transformedAnonGid , err := expandFilestoreInstanceFileSharesNfsExportOptionsAnonGid (original ["anon_gid" ], d , config )
884
+ if err != nil {
885
+ return nil , err
886
+ } else if val := reflect .ValueOf (transformedAnonGid ); val .IsValid () && ! isEmptyValue (val ) {
887
+ transformed ["anonGid" ] = transformedAnonGid
888
+ }
889
+
890
+ req = append (req , transformed )
891
+ }
892
+ return req , nil
893
+ }
894
+
895
+ func expandFilestoreInstanceFileSharesNfsExportOptionsIpRanges (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
896
+ return v , nil
897
+ }
898
+
899
+ func expandFilestoreInstanceFileSharesNfsExportOptionsAccessMode (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
900
+ return v , nil
901
+ }
902
+
903
+ func expandFilestoreInstanceFileSharesNfsExportOptionsSquashMode (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
904
+ return v , nil
905
+ }
906
+
907
+ func expandFilestoreInstanceFileSharesNfsExportOptionsAnonUid (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
908
+ return v , nil
909
+ }
910
+
911
+ func expandFilestoreInstanceFileSharesNfsExportOptionsAnonGid (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
912
+ return v , nil
913
+ }
914
+
681
915
func expandFilestoreInstanceNetworks (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
682
916
l := v .([]interface {})
683
917
req := make ([]interface {}, 0 , len (l ))
@@ -716,6 +950,13 @@ func expandFilestoreInstanceNetworks(v interface{}, d TerraformResourceData, con
716
950
transformed ["ipAddresses" ] = transformedIpAddresses
717
951
}
718
952
953
+ transformedConnectMode , err := expandFilestoreInstanceNetworksConnectMode (original ["connect_mode" ], d , config )
954
+ if err != nil {
955
+ return nil , err
956
+ } else if val := reflect .ValueOf (transformedConnectMode ); val .IsValid () && ! isEmptyValue (val ) {
957
+ transformed ["connectMode" ] = transformedConnectMode
958
+ }
959
+
719
960
req = append (req , transformed )
720
961
}
721
962
return req , nil
@@ -737,6 +978,14 @@ func expandFilestoreInstanceNetworksIpAddresses(v interface{}, d TerraformResour
737
978
return v , nil
738
979
}
739
980
981
+ func expandFilestoreInstanceNetworksConnectMode (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
982
+ return v , nil
983
+ }
984
+
985
+ func expandFilestoreInstanceKmsKeyName (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
986
+ return v , nil
987
+ }
988
+
740
989
func resourceFilestoreInstanceResourceV0 () * schema.Resource {
741
990
return & schema.Resource {
742
991
Schema : map [string ]* schema.Schema {
0 commit comments