func ResourceLogstashPipeline()

in internal/elasticsearch/logstash/pipeline.go [41:183]


func ResourceLogstashPipeline() *schema.Resource {
	logstashPipelineSchema := map[string]*schema.Schema{
		"id": {
			Description: "Internal identifier of the resource",
			Type:        schema.TypeString,
			Computed:    true,
		},
		"pipeline_id": {
			Description: "Identifier for the pipeline.",
			Type:        schema.TypeString,
			Required:    true,
			ForceNew:    true,
		},
		"description": {
			Description: "Description of the pipeline.",
			Type:        schema.TypeString,
			Optional:    true,
		},
		"last_modified": {
			Description: "Date the pipeline was last updated.",
			Type:        schema.TypeString,
			Computed:    true,
		},
		"pipeline": {
			Description: "Configuration for the pipeline.",
			Type:        schema.TypeString,
			Required:    true,
		},
		"pipeline_metadata": {
			Description:      "Optional JSON metadata about the pipeline.",
			Type:             schema.TypeString,
			ValidateFunc:     validation.StringIsJSON,
			DiffSuppressFunc: utils.DiffJsonSuppress,
			Optional:         true,
			Default:          "{\"type\":\"logstash_pipeline\",\"version\":1}",
		},
		// Pipeline Settings
		"pipeline_batch_delay": {
			Description: "Time in milliseconds to wait for each event before sending an undersized batch to pipeline workers.",
			Type:        schema.TypeInt,
			Optional:    true,
		},
		"pipeline_batch_size": {
			Description: "The maximum number of events an individual worker thread collects before executing filters and outputs.",
			Type:        schema.TypeInt,
			Optional:    true,
		},
		"pipeline_ecs_compatibility": {
			Description:  "Sets the pipeline default value for ecs_compatibility, a setting that is available to plugins that implement an ECS compatibility mode for use with the Elastic Common Schema.",
			Type:         schema.TypeString,
			ValidateFunc: validation.StringInSlice([]string{"disabled", "v1", "v8"}, false),
			Optional:     true,
		},
		"pipeline_ordered": {
			Description:  "Set the pipeline event ordering.",
			Type:         schema.TypeString,
			ValidateFunc: validation.StringInSlice([]string{"auto", "true", "false"}, false),
			Optional:     true,
		},
		"pipeline_plugin_classloaders": {
			Description: "(Beta) Load Java plugins in independent classloaders to isolate their dependencies.",
			Type:        schema.TypeBool,
			Optional:    true,
		},
		"pipeline_unsafe_shutdown": {
			Description: "Forces Logstash to exit during shutdown even if there are still inflight events in memory.",
			Type:        schema.TypeBool,
			Optional:    true,
		},
		"pipeline_workers": {
			Description:  "The number of parallel workers used to run the filter and output stages of the pipeline.",
			Type:         schema.TypeInt,
			Optional:     true,
			ValidateFunc: validation.IntAtLeast(1),
		},
		"queue_checkpoint_acks": {
			Description: "The maximum number of ACKed events before forcing a checkpoint when persistent queues are enabled.",
			Type:        schema.TypeInt,
			Optional:    true,
		},
		"queue_checkpoint_retry": {
			Description: "When enabled, Logstash will retry four times per attempted checkpoint write for any checkpoint writes that fail. Any subsequent errors are not retried.",
			Type:        schema.TypeBool,
			Optional:    true,
		},
		"queue_checkpoint_writes": {
			Description: "The maximum number of written events before forcing a checkpoint when persistent queues are enabled.",
			Type:        schema.TypeInt,
			Optional:    true,
		},
		"queue_drain": {
			Description: "When enabled, Logstash waits until the persistent queue is drained before shutting down.",
			Type:        schema.TypeBool,
			Optional:    true,
		},
		"queue_max_bytes": {
			Description:  "Units for the total capacity of the queue when persistent queues are enabled.",
			Type:         schema.TypeString,
			ValidateFunc: validation.StringMatch(regexp.MustCompile("^[0-9]+[kmgtp]?b$"), "must be valid size unit"),
			Optional:     true,
		},
		"queue_max_events": {
			Description: "The maximum number of unread events in the queue when persistent queues are enabled.",
			Type:        schema.TypeInt,
			Optional:    true,
		},
		"queue_page_capacity": {
			Description: "The size of the page data files used when persistent queues are enabled. The queue data consists of append-only data files separated into pages.",
			Type:        schema.TypeString,
			Optional:    true,
		},
		"queue_type": {
			Description:  "The internal queueing model for event buffering. Options are memory for in-memory queueing, or persisted for disk-based acknowledged queueing.",
			Type:         schema.TypeString,
			ValidateFunc: validation.StringInSlice([]string{"memory", "persisted"}, false),
			Optional:     true,
		},
		// Pipeline Settings - End
		"username": {
			Description: "User who last updated the pipeline.",
			Type:        schema.TypeString,
			Optional:    true,
			DefaultFunc: schema.EnvDefaultFunc("ELASTICSEARCH_USERNAME", "api_key"),
		},
	}

	utils.AddConnectionSchema(logstashPipelineSchema)

	return &schema.Resource{
		Description: "Manage Logstash Pipelines via Centralized Pipeline Management. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/logstash-apis.html",

		CreateContext: resourceLogstashPipelinePut,
		UpdateContext: resourceLogstashPipelinePut,
		ReadContext:   resourceLogstashPipelineRead,
		DeleteContext: resourceLogstashPipelineDelete,

		Importer: &schema.ResourceImporter{
			StateContext: schema.ImportStatePassthroughContext,
		},

		Schema: logstashPipelineSchema,
	}
}