Last active
December 7, 2023 19:06
-
-
Save RoseSecurity/6428d8f945c3853f0d0b3cfc42853b80 to your computer and use it in GitHub Desktop.
A comprehensive way to interact with Elasticsearch's Terraform provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = ">= 1.5.5" | |
required_providers { | |
elasticstack = { | |
source = "elastic/elasticstack" | |
version = ">= 0.9.0" | |
} | |
} | |
} | |
provider "elasticstack" { | |
elasticsearch { | |
username = var.elasticsearch_username | |
password = var.elasticsearch_password | |
endpoints = var.elasticsearch_endpoints | |
insecure = var.elasticsearch_insecure | |
api_key = var.api_key | |
ca_data = var.ca_data | |
ca_file = var.ca_file | |
cert_data = var.cert_data | |
cert_file = var.cert_file | |
key_data = var.key_data | |
key_file = var.key_file | |
} | |
} | |
# Elasticsearch provider variables | |
variable "api_key" { | |
type = string | |
description = "API Key to use for authentication to Elasticsearch" | |
sensitive = true | |
default = null | |
} | |
variable "ca_data" { | |
type = string | |
description = "PEM-encoded custom Certificate Authority certificate" | |
default = null | |
} | |
variable "ca_file" { | |
type = string | |
description = "Path to a custom Certificate Authority certificate" | |
default = null | |
} | |
variable "cert_data" { | |
type = string | |
description = "PEM encoded certificate for client auth" | |
default = null | |
} | |
variable "cert_file" { | |
type = string | |
description = "Path to a file containing the PEM encoded certificate for client auth" | |
default = null | |
} | |
variable "elasticsearch_endpoints" { | |
type = list(string) | |
description = "A list of endpoints where the Terraform provider will point to, including the http(s) schema and port number" | |
sensitive = true | |
} | |
variable "elasticsearch_insecure" { | |
type = bool | |
description = "Disable TLS certificate validation" | |
default = true | |
} | |
variable "key_data" { | |
type = string | |
description = "PEM encoded private key for client auth" | |
sensitive = true | |
default = null | |
} | |
variable "key_file" { | |
type = string | |
description = "Path to a file containing the PEM encoded private key for client auth" | |
default = null | |
} | |
variable "elasticsearch_password" { | |
type = string | |
description = "Password to use for API authentication to Elasticsearch" | |
sensitive = true | |
} | |
variable "elasticsearch_username" { | |
type = string | |
description = "Username to use for API authentication to Elasticsearch" | |
default = "elastic" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Elasticsearch | |
elasticsearch_endpoints = ["https://127.0.0.1:9200"] | |
elasticsearch_password = "random_password" | |
elasticsearch_username = "elastic" | |
insecure = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment