elastic / terraform-provider-elasticstack

Terraform provider for Elastic Stack
https://registry.terraform.io/providers/elastic/elasticstack/latest/docs
Apache License 2.0
173 stars 93 forks source link

[Bug] elasticstack_elasticsearch_data_stream_lifecycle data_retention serialization issue on apply #926

Open howtwizer opened 3 days ago

howtwizer commented 3 days ago

Describe the bug Truing to apply

resource "elasticstack_elasticsearch_data_stream_lifecycle" "proxy_log_data_stream_lifecycle_multiple" {
  name           = "logs-proxy-*"
  data_retention = "30d"
}

Failing with error

│ Error: json: cannot unmarshal object into Go value of type []models.DataStreamLifecycle
│ 
│   with elasticstack_elasticsearch_data_stream_lifecycle.proxy_log_data_stream_lifecycle_multiple,
│   on data-stream-lifecycles.tf line 1, in resource "elasticstack_elasticsearch_data_stream_lifecycle" "proxy_log_data_stream_lifecycle_multiple":
│    1: resource "elasticstack_elasticsearch_data_stream_lifecycle" "proxy_log_data_stream_lifecycle_multiple" {
│ 

To Reproduce Steps to reproduce the behavior:

  1. TF configuration used '
    
    required_version = ">= 0.12"
    required_providers {
    elasticstack = {
      source  = "elastic/elasticstack"
      version = "0.11.11"
    }
    }```'
  2. TF operations to execute to get the error 'terraform apply'
  3. See the error in the output '
    
    2024-11-22T13:02:01.692+0100 [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
    2024-11-22T13:02:01.698+0100 [INFO]  provider: configuring client automatic mTLS
    2024-11-22T13:02:01.727+0100 [INFO]  provider.terraform-provider-elasticstack_v0.11.11: configuring server automatic mTLS: timestamp="2024-11-22T13:02:01.726+0100"
    elasticstack_elasticsearch_data_stream_lifecycle.proxy_log_data_stream_lifecycle_multiple: Creating...
    2024-11-22T13:02:01.747+0100 [INFO]  Starting apply for elasticstack_elasticsearch_data_stream_lifecycle.proxy_log_data_stream_lifecycle_multiple
    2024-11-22T13:02:03.356+0100 [ERROR] provider.terraform-provider-elasticstack_v0.11.11: Response contains error diagnostic: @module=sdk.proto diagnostic_severity=ERROR diagnostic_summary="json: cannot unmarshal object into Go value of type []models.DataStreamLifecycle" tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/internal/diag/diagnostics.go:58 diagnostic_detail="" tf_proto_version=6.6 tf_provider_addr=registry.terraform.io/elastic/elasticstack tf_req_id=e79a338f-0d81-e149-7716-e91b036fdd73 tf_resource_type=elasticstack_elasticsearch_data_stream_lifecycle timestamp="2024-11-22T13:02:03.356+0100"
    2024-11-22T13:02:03.358+0100 [ERROR] vertex "elasticstack_elasticsearch_data_stream_lifecycle.proxy_log_data_stream_lifecycle_multiple" error: json: cannot unmarshal object into Go value of type []models.DataStreamLifecycle
    ╷
    │ Error: json: cannot unmarshal object into Go value of type []models.DataStreamLifecycle
    │ 
    │   with elasticstack_elasticsearch_data_stream_lifecycle.proxy_log_data_stream_lifecycle_multiple,
    │   on data-stream-lifecycles.tf line 1, in resource "elasticstack_elasticsearch_data_stream_lifecycle" "proxy_log_data_stream_lifecycle_multiple":
    │    1: resource "elasticstack_elasticsearch_data_stream_lifecycle" "proxy_log_data_stream_lifecycle_multiple" {
    │ 
    ╵
    ```'

Expected behavior Create Data stream retention policy with 30d retention period for data streams "logs-proxy-*"