splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
103 stars 75 forks source link

Index Module(MaxHotBuckets) for v8.2 not recognized #124

Open romedawg opened 2 years ago

romedawg commented 2 years ago

In v8.2, a string is returned for maxHotBuckets when terraform is making an api request against for indexes. The maxHotBuckets was an integer in previous version, which is what terraform-provider-splunk is expecting here

Rest api url: https://splunkserver.com/services/data/indexes?output_mode=json

maxHotBuckets":"3"

Splunk documents this change in the index.conf 8.0.3 indexes.conf doc:

maxHotBuckets = <positive integer>
...
* Default: 3

8.2.6 indexes.conf doc:

maxHotBuckets = <positive integer> | auto
...
* Default: "auto"

The result is that terraform is trying to update the maxHotBuckets every time a plan is created, so in my case,

# module.indexes.module.indexes.module.test-module.test-uat.splunk_indexes.index will be updated in-place
  ~ resource "splunk_indexes" "index" {
        block_sign_size                  = 0
        cold_path                        = "$SPLUNK_DB/test/colddb"
        compress_rawdata                 = true
        datatype                         = "event"
        enable_online_bucket_repair      = true
        frozen_time_period_in_secs       = 188697600
        home_path                        = "$SPLUNK_DB/test/db"
        id                               = "test"
        max_bloom_backfill_bucket_age    = "30d"
        max_concurrent_optimizes         = 6
        max_data_size                    = "auto"
      ~ max_hot_buckets                  = 0 -> 3
        max_hot_idle_secs                = 0
        max_hot_span_secs                = 7776000
        max_mem_mb                       = 5
        max_meta_entries                 = 1000000
        max_time_unreplicated_no_acks    = 300
        max_time_unreplicated_with_acks  = 60
        max_total_data_size_mb           = 10240
        max_warm_db_count                = 300
        min_raw_file_sync_secs           = "disable"
        min_stream_group_queue_size      = 2000
        name                             = "test"
        partial_service_meta_period      = 0
        process_tracker_service_interval = 1
        quarantine_future_secs           = 2592000
        quarantine_past_secs             = 77760000
        raw_chunk_size_bytes             = 131072
        rotate_period_in_secs            = 60
        service_meta_period              = 25
        sync_meta                        = true
        thawed_path                      = "$SPLUNK_DB/test/thaweddb"
        throttle_check_period            = 15
        tstats_home_path                 = "volume:_splunk_summaries/$_index_name/datamodel_summary"

        acl {
            app              = "search"
            can_change_perms = false
            can_share_app    = false
            can_share_global = false
            can_share_user   = false
            can_write        = true
            owner            = "nobody"
            read             = [
                "*",
            ]
            removable        = true
            sharing          = "app"
            write            = [
                "admin",
                "splunk-system-role",
            ]
        }
    }

ResourceData.Get why the provider returns a 0.

If the key does exist in the schema but doesn't exist in the configuration, then the default value for that type will be returned. For strings, this is "", for numbers it is 0, etc

Applying the above plan has no affect on the max_hot_buckets.

One option for v8.2 is the change the data type to String here, here and here. Then the plan shows no changes

But the provider needs a solution to support both 8.2 and previous versions.

Update Looks like this is being addressed in this PR