-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Unable to get a user/role #377
Comments
i'm not clear on where this was tested. On a basic licensed cluster, or on Elastic Cloud? if so, it seems the problem is the basic license. |
Hi @Kushmaro, We're using Elastic Cloud with a single Elasticsearch instance and a Kibana instance. Our Terraform code was working before. But as mentioned we're not able to identify what specifically broke it. |
@orlandothoeny well its quite hard to determine what broke with the code itself. Can you share the relevant piece? |
Here is a simplified version of the code we're using.
provider "ec" {
// ...
}
resource "ec_deployment" "deployment" {
name = "my-deployment-dev"
alias = "my-deployment-dev"
region = "europe-west4"
version = "7.17.9"
deployment_template_id = "gcp-storage-optimized"
elasticsearch = {
ref_id = "main-elasticsearch"
autoscale = "false"
hot = {
autoscaling = {}
}
topology = {
id = "hot_content"
zone_count = 1
size = "2g"
size_resource = "memory"
}
}
kibana = {
ref_id = "kibana"
topology = {
size = "1g"
size_resource = "memory"
}
}
observability = {
deployment_id = "self"
logs = false
metrics = true
}
}
provider "elasticstack" {
elasticsearch {
endpoints = [ec_deployment.deployment.elasticsearch.https_endpoint]
username = ec_deployment.deployment.elasticsearch_username
password = ec_deployment.deployment.elasticsearch_password
}
}
resource "elasticstack_elasticsearch_security_user" "terraform_user" {
username = "terraform"
password = "foo"
roles = ["superuser"]
}
resource "elasticstack_elasticsearch_security_user" "datadog_user" {
username = "datadog"
password = "bar"
/* We still need the "monitoring_user" user role, because we cannot assign the Kibana "Stack Monitoring" permission to our own custom "datadog" role.
These are only available via this built-in role */
roles = [elasticstack_elasticsearch_security_role.datadog_role.name, "monitoring_user"]
}
resource "elasticstack_elasticsearch_security_role" "datadog_role" {
name = "datadog"
indices {
names = [".monitoring-*", "metricbeat-*"]
privileges = ["read", "read_cross_cluster", "monitor"]
}
cluster = ["monitor"]
run_as = []
} |
Hi @Kushmaro, I also tried it by using explicit per-resource definitions ( provider "ec" {
// ...
}
resource "ec_deployment" "deployment" {
name = "my-deployment-dev"
alias = "my-deployment-dev"
region = "europe-west4"
version = "7.17.9"
deployment_template_id = "gcp-storage-optimized"
elasticsearch = {
ref_id = "main-elasticsearch"
autoscale = "false"
hot = {
autoscaling = {}
}
topology = {
id = "hot_content"
zone_count = 1
size = "2g"
size_resource = "memory"
}
}
kibana = {
ref_id = "kibana"
topology = {
size = "1g"
size_resource = "memory"
}
}
observability = {
deployment_id = "self"
logs = false
metrics = true
}
}
provider "elasticstack" {
elasticsearch {}
}
resource "elasticstack_elasticsearch_security_user" "terraform_user" {
username = "terraform"
password = "foo"
roles = ["superuser"]
elasticsearch_connection {
endpoints = [ec_deployment.deployment.elasticsearch.https_endpoint]
username = ec_deployment.deployment.elasticsearch_username
password = ec_deployment.deployment.elasticsearch_password
}
}
resource "elasticstack_elasticsearch_security_user" "datadog_user" {
username = "datadog"
password = "bar"
/* We still need the "monitoring_user" user role, because we cannot assign the Kibana "Stack Monitoring" permission to our own custom "datadog" role.
These are only available via this built-in role */
roles = [elasticstack_elasticsearch_security_role.datadog_role.name, "monitoring_user"]
elasticsearch_connection {
endpoints = [ec_deployment.deployment.elasticsearch.https_endpoint]
username = ec_deployment.deployment.elasticsearch_username
password = ec_deployment.deployment.elasticsearch_password
}
}
resource "elasticstack_elasticsearch_security_role" "datadog_role" {
name = "datadog"
indices {
names = [".monitoring-*", "metricbeat-*"]
privileges = ["read", "read_cross_cluster", "monitor"]
}
cluster = ["monitor"]
run_as = []
elasticsearch_connection {
endpoints = [ec_deployment.deployment.elasticsearch.https_endpoint]
username = ec_deployment.deployment.elasticsearch_username
password = ec_deployment.deployment.elasticsearch_password
}
} |
Seems like the root cause is actually #370 Managed to get it to work by using the workaround described in that issue. |
Hello,
We are running an Elastic Cloud instance, which is managed using Terraform.
We use the
elasticstack_elasticsearch_security_user
&elasticstack_elasticsearch_security_role
resources to create users & roles.The following error occurs during the state refresh when Elasticsearch users/roles are fetched while running
terraform apply
: "Security must be explicitly enabled when using a [basic] license. Enable security by setting [xpack.security.enabled] to [true] in the elasticsearch.yml file and restart the node."Our code was working before, it broke at some point. Unfortunately, I cannot identify the exact reason. Might be due to an elasticstack provider update or an Elasticsearch server update.
The weird thing is, calling the API using curl works, the following returns JSON containing our Elasticsearch users.
I tried setting the
![Screenshot from 2023-07-04 10-32-48](https://private-user-images.githubusercontent.com/17168783/250847689-8e0d6412-808a-4e79-872a-6378856b928a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MzM2NzIsIm5iZiI6MTczOTQzMzM3MiwicGF0aCI6Ii8xNzE2ODc4My8yNTA4NDc2ODktOGUwZDY0MTItODA4YS00ZTc5LTg3MmEtNjM3ODg1NmI5MjhhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDA3NTYxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjMjE5NDQ2ZmM4NTM3OTkzOWUwNmFmMDBiZTBjMzQ3MDk5ZWIwYmMzMmU1YzRjZjgwODM3M2JkNzNjMzM3NWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Sqeo_oyx46ilesmGHE6GLiUSl5u3VAv8dKVInv58gcI)
xpack.security.enabled: true
config explicitly but that's not possible on Elastic Cloud:Terraform errors
Debug output
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: