Skip to content

Commit

Permalink
Merge pull request #23 from terraform-providers/fix-#21
Browse files Browse the repository at this point in the history
fix: importing a mongodbatlas_project_ip_whitelist resource does not save project_id to state
  • Loading branch information
PacoDw authored Sep 11, 2019
2 parents 1aa20ec + 2ff562c commit 7c141ce
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mongodbatlas/resource_mongodbatlas_project_ip_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,20 @@ func resourceMongoDBAtlasProjectIPWhitelistImportState(d *schema.ResourceData, m
entries = append(entries, entry)
})

if err := d.Set("project_id", d.Id()); err != nil {
log.Printf("[WARN] Error setting project_id for (%s): %s", d.Id(), err)
return []*schema.ResourceData{d}, err
}
if err := d.Set("whitelist", flattenProjectIPWhitelist(whitelist)); err != nil {
log.Printf("[WARN] Error setting whitelist for (%s): %s", d.Id(), err)
return []*schema.ResourceData{d}, err
}

d.SetId(encodeStateID(map[string]string{
"project_id": d.Id(),
"entries": strings.Join(entries, ","),
}))

if err := d.Set("whitelist", flattenProjectIPWhitelist(whitelist)); err != nil {
log.Printf("[WARN] Error setting project_id for (%s): %s", d.Id(), err)
return []*schema.ResourceData{d}, err
}

return []*schema.ResourceData{d}, nil
}

Expand Down

0 comments on commit 7c141ce

Please sign in to comment.