@@ -184,6 +184,40 @@ Maintenance window is not needed for services with the 'SPANNER' database type.`
184
184
185
185
"projects/{projectNumber}/global/networks/{network_id}".` ,
186
186
},
187
+ "network_config" : {
188
+ Type : schema .TypeList ,
189
+ Optional : true ,
190
+ ForceNew : true ,
191
+ Description : `The configuration specifying the network settings for the Dataproc Metastore service.` ,
192
+ MaxItems : 1 ,
193
+ Elem : & schema.Resource {
194
+ Schema : map [string ]* schema.Schema {
195
+ "consumers" : {
196
+ Type : schema .TypeList ,
197
+ Required : true ,
198
+ ForceNew : true ,
199
+ Description : `The consumer-side network configuration for the Dataproc Metastore instance.` ,
200
+ Elem : & schema.Resource {
201
+ Schema : map [string ]* schema.Schema {
202
+ "subnetwork" : {
203
+ Type : schema .TypeString ,
204
+ Required : true ,
205
+ Description : `The subnetwork of the customer project from which an IP address is reserved and used as the Dataproc Metastore service's endpoint.
206
+ It is accessible to hosts in the subnet and to all hosts in a subnet in the same region and same network.
207
+ There must be at least one IP address available in the subnet's primary range. The subnet is specified in the following form:
208
+ 'projects/{projectNumber}/regions/{region_id}/subnetworks/{subnetwork_id}` ,
209
+ },
210
+ "endpoint_uri" : {
211
+ Type : schema .TypeString ,
212
+ Computed : true ,
213
+ Description : `The URI of the endpoint used to access the metastore service.` ,
214
+ },
215
+ },
216
+ },
217
+ },
218
+ },
219
+ },
220
+ },
187
221
"port" : {
188
222
Type : schema .TypeInt ,
189
223
Computed : true ,
@@ -296,6 +330,12 @@ func resourceDataprocMetastoreServiceCreate(d *schema.ResourceData, meta interfa
296
330
} else if v , ok := d .GetOkExists ("hive_metastore_config" ); ! isEmptyValue (reflect .ValueOf (hiveMetastoreConfigProp )) && (ok || ! reflect .DeepEqual (v , hiveMetastoreConfigProp )) {
297
331
obj ["hiveMetastoreConfig" ] = hiveMetastoreConfigProp
298
332
}
333
+ networkConfigProp , err := expandDataprocMetastoreServiceNetworkConfig (d .Get ("network_config" ), d , config )
334
+ if err != nil {
335
+ return err
336
+ } else if v , ok := d .GetOkExists ("network_config" ); ! isEmptyValue (reflect .ValueOf (networkConfigProp )) && (ok || ! reflect .DeepEqual (v , networkConfigProp )) {
337
+ obj ["networkConfig" ] = networkConfigProp
338
+ }
299
339
databaseTypeProp , err := expandDataprocMetastoreServiceDatabaseType (d .Get ("database_type" ), d , config )
300
340
if err != nil {
301
341
return err
@@ -425,6 +465,9 @@ func resourceDataprocMetastoreServiceRead(d *schema.ResourceData, meta interface
425
465
if err := d .Set ("hive_metastore_config" , flattenDataprocMetastoreServiceHiveMetastoreConfig (res ["hiveMetastoreConfig" ], d , config )); err != nil {
426
466
return fmt .Errorf ("Error reading Service: %s" , err )
427
467
}
468
+ if err := d .Set ("network_config" , flattenDataprocMetastoreServiceNetworkConfig (res ["networkConfig" ], d , config )); err != nil {
469
+ return fmt .Errorf ("Error reading Service: %s" , err )
470
+ }
428
471
if err := d .Set ("database_type" , flattenDataprocMetastoreServiceDatabaseType (res ["databaseType" ], d , config )); err != nil {
429
472
return fmt .Errorf ("Error reading Service: %s" , err )
430
473
}
@@ -787,6 +830,46 @@ func flattenDataprocMetastoreServiceHiveMetastoreConfigKerberosConfigKrb5ConfigG
787
830
return v
788
831
}
789
832
833
+ func flattenDataprocMetastoreServiceNetworkConfig (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
834
+ if v == nil {
835
+ return nil
836
+ }
837
+ original := v .(map [string ]interface {})
838
+ if len (original ) == 0 {
839
+ return nil
840
+ }
841
+ transformed := make (map [string ]interface {})
842
+ transformed ["consumers" ] =
843
+ flattenDataprocMetastoreServiceNetworkConfigConsumers (original ["consumers" ], d , config )
844
+ return []interface {}{transformed }
845
+ }
846
+ func flattenDataprocMetastoreServiceNetworkConfigConsumers (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
847
+ if v == nil {
848
+ return v
849
+ }
850
+ l := v .([]interface {})
851
+ transformed := make ([]interface {}, 0 , len (l ))
852
+ for _ , raw := range l {
853
+ original := raw .(map [string ]interface {})
854
+ if len (original ) < 1 {
855
+ // Do not include empty json objects coming back from the api
856
+ continue
857
+ }
858
+ transformed = append (transformed , map [string ]interface {}{
859
+ "endpoint_uri" : flattenDataprocMetastoreServiceNetworkConfigConsumersEndpointUri (original ["endpointUri" ], d , config ),
860
+ "subnetwork" : flattenDataprocMetastoreServiceNetworkConfigConsumersSubnetwork (original ["subnetwork" ], d , config ),
861
+ })
862
+ }
863
+ return transformed
864
+ }
865
+ func flattenDataprocMetastoreServiceNetworkConfigConsumersEndpointUri (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
866
+ return v
867
+ }
868
+
869
+ func flattenDataprocMetastoreServiceNetworkConfigConsumersSubnetwork (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
870
+ return v
871
+ }
872
+
790
873
func flattenDataprocMetastoreServiceDatabaseType (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
791
874
return v
792
875
}
@@ -991,6 +1074,62 @@ func expandDataprocMetastoreServiceHiveMetastoreConfigKerberosConfigKrb5ConfigGc
991
1074
return v , nil
992
1075
}
993
1076
1077
+ func expandDataprocMetastoreServiceNetworkConfig (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1078
+ l := v .([]interface {})
1079
+ if len (l ) == 0 || l [0 ] == nil {
1080
+ return nil , nil
1081
+ }
1082
+ raw := l [0 ]
1083
+ original := raw .(map [string ]interface {})
1084
+ transformed := make (map [string ]interface {})
1085
+
1086
+ transformedConsumers , err := expandDataprocMetastoreServiceNetworkConfigConsumers (original ["consumers" ], d , config )
1087
+ if err != nil {
1088
+ return nil , err
1089
+ } else if val := reflect .ValueOf (transformedConsumers ); val .IsValid () && ! isEmptyValue (val ) {
1090
+ transformed ["consumers" ] = transformedConsumers
1091
+ }
1092
+
1093
+ return transformed , nil
1094
+ }
1095
+
1096
+ func expandDataprocMetastoreServiceNetworkConfigConsumers (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1097
+ l := v .([]interface {})
1098
+ req := make ([]interface {}, 0 , len (l ))
1099
+ for _ , raw := range l {
1100
+ if raw == nil {
1101
+ continue
1102
+ }
1103
+ original := raw .(map [string ]interface {})
1104
+ transformed := make (map [string ]interface {})
1105
+
1106
+ transformedEndpointUri , err := expandDataprocMetastoreServiceNetworkConfigConsumersEndpointUri (original ["endpoint_uri" ], d , config )
1107
+ if err != nil {
1108
+ return nil , err
1109
+ } else if val := reflect .ValueOf (transformedEndpointUri ); val .IsValid () && ! isEmptyValue (val ) {
1110
+ transformed ["endpointUri" ] = transformedEndpointUri
1111
+ }
1112
+
1113
+ transformedSubnetwork , err := expandDataprocMetastoreServiceNetworkConfigConsumersSubnetwork (original ["subnetwork" ], d , config )
1114
+ if err != nil {
1115
+ return nil , err
1116
+ } else if val := reflect .ValueOf (transformedSubnetwork ); val .IsValid () && ! isEmptyValue (val ) {
1117
+ transformed ["subnetwork" ] = transformedSubnetwork
1118
+ }
1119
+
1120
+ req = append (req , transformed )
1121
+ }
1122
+ return req , nil
1123
+ }
1124
+
1125
+ func expandDataprocMetastoreServiceNetworkConfigConsumersEndpointUri (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1126
+ return v , nil
1127
+ }
1128
+
1129
+ func expandDataprocMetastoreServiceNetworkConfigConsumersSubnetwork (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1130
+ return v , nil
1131
+ }
1132
+
994
1133
func expandDataprocMetastoreServiceDatabaseType (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
995
1134
return v , nil
996
1135
}
0 commit comments