Skip to content

INTMDB:273: Fix replication_specs update error #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/automated-test-acceptances.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Automated Acceptances Tests'
name: 'Automated Acceptance Tests'

on:
push:
Expand All @@ -24,7 +24,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

acceptances-tests:
acceptance-tests:
if: ${{ github.event.label.name == 'run-testacc' || github.ref == 'refs/heads/master' }}
needs: [ authorize ]
runs-on: ubuntu-latest
Expand Down
7 changes: 6 additions & 1 deletion mongodbatlas/resource_mongodbatlas_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ func resourceMongoDBAtlasCluster() *schema.Resource {
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"num_shards": {
Expand Down Expand Up @@ -1176,14 +1177,18 @@ func expandReplicationSpecs(d *schema.ResourceData) ([]matlas.ReplicationSpec, e

if d.HasChange("replication_specs") {
// Get original and new object
var oldSpecs map[string]interface{}
original, _ := d.GetChange("replication_specs")
for _, s := range original.(*schema.Set).List() {
oldSpecs := s.(map[string]interface{})
oldSpecs = s.(map[string]interface{})
if spec["zone_name"].(string) == cast.ToString(oldSpecs["zone_name"]) {
id = oldSpecs["id"].(string)
break
}
}
if id == "" && oldSpecs != nil {
id = oldSpecs["id"].(string)
}
}

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