Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions internal/elasticsearch/cluster/slm.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/models"
"github.com/elastic/terraform-provider-elasticstack/internal/utils"
"github.com/hashicorp/go-cty/cty"
"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 @@ -250,6 +251,7 @@ func resourceSlmRead(ctx context.Context, d *schema.ResourceData, meta interface

slm, diags := client.GetElasticsearchSlm(ctx, id.ResourceId)
if slm == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`SLM policy "%s" not found, removing from state`, id.ResourceId))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/index/component_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package index
import (
"context"
"encoding/json"
"fmt"
"strings"

"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 @@ -238,6 +240,7 @@ func resourceComponentTemplateRead(ctx context.Context, d *schema.ResourceData,

tpl, diags := client.GetElasticsearchComponentTemplate(ctx, templateId)
if tpl == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Component template "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/index/data_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package index
import (
"context"
"encoding/json"
"fmt"
"regexp"

"github.com/elastic/terraform-provider-elasticstack/internal/clients"
"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 @@ -149,6 +151,7 @@ func resourceDataStreamRead(ctx context.Context, d *schema.ResourceData, meta in
ds, diags := client.GetElasticsearchDataStream(ctx, compId.ResourceId)
if ds == nil && diags == nil {
// no data stream found on ES side
tflog.Warn(ctx, fmt.Sprintf(`Data stream "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down
2 changes: 2 additions & 0 deletions internal/elasticsearch/index/ilm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 @@ -540,6 +541,7 @@ func resourceIlmRead(ctx context.Context, d *schema.ResourceData, meta interface

ilmDef, diags := client.GetElasticsearchIlm(ctx, policyId)
if ilmDef == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`ILM policy "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down
1 change: 1 addition & 0 deletions internal/elasticsearch/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ func resourceIndexRead(ctx context.Context, d *schema.ResourceData, meta interfa
index, diags := client.GetElasticsearchIndex(ctx, indexName)
if index == nil && diags == nil {
// no index found on ES side
tflog.Warn(ctx, fmt.Sprintf(`Index "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/index/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package index
import (
"context"
"encoding/json"
"fmt"
"strings"

"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 @@ -315,6 +317,7 @@ func resourceIndexTemplateRead(ctx context.Context, d *schema.ResourceData, meta

tpl, diags := client.GetElasticsearchIndexTemplate(ctx, templateId)
if tpl == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Index template "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/ingest/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package ingest
import (
"context"
"encoding/json"
"fmt"
"strings"

"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 @@ -148,6 +150,7 @@ func resourceIngestPipelineTemplateRead(ctx context.Context, d *schema.ResourceD

pipeline, diags := client.GetElasticsearchIngestPipeline(ctx, &compId.ResourceId)
if pipeline == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Injest pipeline "%s" not found, removing from state`, compId.ResourceId))
d.SetId("")
return diags
}
Expand Down
1 change: 1 addition & 0 deletions internal/elasticsearch/logstash/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func resourceLogstashPipelineRead(ctx context.Context, d *schema.ResourceData, m

logstashPipeline, diags := client.GetLogstashPipeline(ctx, resourceID)
if logstashPipeline == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Logstash pipeline "%s" not found, removing from state`, resourceID))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/security/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package security
import (
"context"
"encoding/json"
"fmt"
"strings"

"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 @@ -322,6 +324,7 @@ func resourceSecurityRoleRead(ctx context.Context, d *schema.ResourceData, meta

role, diags := client.GetElasticsearchRole(ctx, roleId)
if role == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Role "%s" not found, removing from state`, roleId))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/security/role_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package security
import (
"context"
"encoding/json"
"fmt"

"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"
)
Expand Down Expand Up @@ -130,6 +132,7 @@ func resourceSecurityRoleMappingRead(ctx context.Context, d *schema.ResourceData
}
roleMapping, diags := client.GetElasticsearchRoleMapping(ctx, resourceID)
if roleMapping == nil && diags == nil {
tflog.Warn(ctx, fmt.Sprintf(`Role mapping "%s" not found, removing from state`, resourceID))
d.SetId("")
return diags
}
Expand Down
3 changes: 3 additions & 0 deletions internal/elasticsearch/security/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package security
import (
"context"
"encoding/json"
"fmt"
"regexp"
"strings"

"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 @@ -171,6 +173,7 @@ func resourceSecurityUserRead(ctx context.Context, d *schema.ResourceData, meta

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