@@ -219,8 +219,6 @@ func processRepSpecsClusterWithDynamicBlock(resourceb *hclwrite.Body, root attrV
219
219
if err != nil {
220
220
return dynamicBlock {}, err
221
221
}
222
-
223
- // Check if we have a dynamic region_configs block that was successfully processed
224
222
if dConfig .tokens != nil {
225
223
forSpec := hcl .TokensFromExpr (buildForExpr (nSpec , hcl .GetAttrExpr (dSpec .forEach ), true ))
226
224
forSpec = append (forSpec , dConfig .tokens ... )
@@ -231,31 +229,9 @@ func processRepSpecsClusterWithDynamicBlock(resourceb *hclwrite.Body, root attrV
231
229
232
230
// Handle static region_configs blocks inside dynamic replication_specs
233
231
specBody := dSpec .content .Body ()
234
-
235
- // Collect static region_configs blocks
236
232
staticConfigs := collectBlocks (specBody , nConfigSrc )
237
- if len (staticConfigs ) == 0 {
238
- // No static blocks found, check if there's also no dynamic block
239
- hasDynamicBlock := false
240
- for _ , block := range specBody .Blocks () {
241
- if block .Type () == nDynamic && getResourceName (block ) == nConfigSrc {
242
- hasDynamicBlock = true
243
- break
244
- }
245
- }
246
- if ! hasDynamicBlock {
247
- return dynamicBlock {}, fmt .Errorf ("replication_specs must have at least one regions_config" )
248
- }
249
- // There's a dynamic block but fillConfigsWithDynamicRegion returned empty
250
- return dynamicBlock {}, nil
251
- }
252
-
253
233
repSpecb := hclwrite .NewEmptyFile ().Body ()
254
-
255
- // Handle zone_name attribute
256
234
handleZoneName (repSpecb , specBody , nRepSpecs , nSpec )
257
-
258
- // Process static region_configs blocks
259
235
var configs []* hclwrite.Body
260
236
for _ , configBlock := range staticConfigs {
261
237
config , err := getRegionConfig (configBlock , root , false )
@@ -264,16 +240,12 @@ func processRepSpecsClusterWithDynamicBlock(resourceb *hclwrite.Body, root attrV
264
240
}
265
241
configs = append (configs , config )
266
242
}
267
-
268
243
configs = sortConfigsByPriority (configs )
269
244
repSpecb .SetAttributeRaw (nConfig , hcl .TokensArray (configs ))
270
-
271
- // Handle num_shards attribute
272
245
numShardsAttr := specBody .GetAttribute (nNumShards )
273
246
forSpec := hcl .TokensFromExpr (buildForExpr (nSpec , hcl .GetAttrExpr (dSpec .forEach ), true ))
274
247
numShardsTokens := buildNumShardsTokens (numShardsAttr , repSpecb , nRepSpecs , nSpec )
275
248
dSpec .tokens = hcl .TokensFuncFlatten (append (forSpec , numShardsTokens ... ))
276
-
277
249
return dSpec , nil
278
250
}
279
251
0 commit comments