Skip to content

Commit d1ab4f8

Browse files
authored
INTMDB:273: Fix replication_specs update error (#607)
* fix replication_specs update error * fix
1 parent 60bc5e3 commit d1ab4f8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.github/workflows/automated-test-acceptances.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Automated Acceptances Tests'
1+
name: 'Automated Acceptance Tests'
22

33
on:
44
push:
@@ -24,7 +24,7 @@ jobs:
2424
env:
2525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2626

27-
acceptances-tests:
27+
acceptance-tests:
2828
if: ${{ github.event.label.name == 'run-testacc' || github.ref == 'refs/heads/master' }}
2929
needs: [ authorize ]
3030
runs-on: ubuntu-latest

mongodbatlas/resource_mongodbatlas_cluster.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ func resourceMongoDBAtlasCluster() *schema.Resource {
228228
Schema: map[string]*schema.Schema{
229229
"id": {
230230
Type: schema.TypeString,
231+
Optional: true,
231232
Computed: true,
232233
},
233234
"num_shards": {
@@ -1176,14 +1177,18 @@ func expandReplicationSpecs(d *schema.ResourceData) ([]matlas.ReplicationSpec, e
11761177

11771178
if d.HasChange("replication_specs") {
11781179
// Get original and new object
1180+
var oldSpecs map[string]interface{}
11791181
original, _ := d.GetChange("replication_specs")
11801182
for _, s := range original.(*schema.Set).List() {
1181-
oldSpecs := s.(map[string]interface{})
1183+
oldSpecs = s.(map[string]interface{})
11821184
if spec["zone_name"].(string) == cast.ToString(oldSpecs["zone_name"]) {
11831185
id = oldSpecs["id"].(string)
11841186
break
11851187
}
11861188
}
1189+
if id == "" && oldSpecs != nil {
1190+
id = oldSpecs["id"].(string)
1191+
}
11871192
}
11881193

11891194
regionsConfig, err := expandRegionsConfig(spec["regions_config"].(*schema.Set).List(), originalRegion, replaceRegion)

0 commit comments

Comments
 (0)