Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Fixed
- Remove unnecessary unsetting id on delete ([#174](https://github.com/elastic/terraform-provider-elasticstack/pull/174))
- Fix not found handling for snapshot repository ([#175](https://github.com/elastic/terraform-provider-elasticstack/pull/175))

## [0.4.0] - 2022-10-07
### Added
Expand Down
7 changes: 1 addition & 6 deletions internal/clients/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ func (a *ApiClient) GetElasticsearchSnapshotRepository(ctx context.Context, name
}
defer res.Body.Close()
if res.StatusCode == http.StatusNotFound {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "Unable to find requested repository",
Detail: fmt.Sprintf(`Repository "%s" is missing in the ES API response`, name),
})
return nil, diags
return nil, nil
}
if diags := utils.CheckError(res, fmt.Sprintf("Unable to get the information about snapshot repository: %s", name)); diags.HasError() {
return nil, diags
Expand Down
2 changes: 2 additions & 0 deletions internal/elasticsearch/cluster/snapshot_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/elastic/terraform-provider-elasticstack/internal/clients"
"github.com/elastic/terraform-provider-elasticstack/internal/models"
"github.com/elastic/terraform-provider-elasticstack/internal/utils"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -374,6 +375,7 @@ func resourceSnapRepoRead(ctx context.Context, d *schema.ResourceData, meta inte

currentRepo, diags := client.GetElasticsearchSnapshotRepository(ctx, compId.ResourceId)
if currentRepo == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Snapshot repository "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down