-
Notifications
You must be signed in to change notification settings - Fork 56
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
Module should not create role mapping for master_user_arn if advanced_security_options_internal_user_database_enabled enabled #34
Comments
Hi @insider89, Thank you for opening this issue. I think the problem will be that you need to pass username and password in the provider configuration as well: provider "elasticsearch" {
url = module.opensearch.cluster_endpoint
aws_region = "eu-east-1"
healthcheck = false
username = local.admin_credentials.username
password = local.admin_credentials.password
} |
Hi @steveteuber . Just tried to add username and password, but got the same result:
And the error are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_arn["all_access"] will be created
+ resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
+ backend_roles = [
+ "",
]
+ id = (known after apply)
+ role_name = "all_access"
}
# module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_arn["security_manager"] will be created
+ resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
+ backend_roles = [
+ "",
]
+ id = (known after apply)
+ role_name = "security_manager"
}
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_arn["all_access"]: Creating...
module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_arn["security_manager"]: Creating...
╷
│ Error: HTTP 403 Forbidden: Permission denied. Please ensure that the correct credentials are being used to access the cluster.
│
│ with module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_arn["security_manager"],
│ on .terraform/modules/opensearch/role_mapping.tf line 16, in resource "elasticsearch_opensearch_roles_mapping" "master_user_arn":
│ 16: resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
│
╵
╷
│ Error: HTTP 403 Forbidden: Permission denied. Please ensure that the correct credentials are being used to access the cluster.
│
│ with module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_arn["all_access"],
│ on .terraform/modules/opensearch/role_mapping.tf line 16, in resource "elasticsearch_opensearch_roles_mapping" "master_user_arn":
│ 16: resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
│
╵
Releasing state lock. This may take a few moments... |
Now, the role mappings are no longer created when using the internal user database. Could you try it again, please? |
I think you still need to map the role, just it should be done with the internal user instead of Or maybe that's done automatically while creating the cluster, in that case, ignore my message. @insider89 can confirm after applying. I cannot test by myself at the moment |
@egarbi Could you please advice what additional configuration require to map the user instead of |
well, I guess you can pass this variable without having to touch the code (using version role_mappings = {
all_access = {
users = {
[var.advanced_security_options_master_user_name]
}
}
security_manager = {
users = {
[var.advanced_security_options_master_user_name]
}
}
} but again, I'm not sure if that action is actually automatically done when you pass |
@steveteuber @egarbi I can confirm that I don't have an error during applying in v1.4.1. But in the UI I don't see any mapping (should it be?). Please note, that I didn't apply mapping suggested by @egarbi . |
@egarbi I think you are right. But when I remember correctly, the role mappings are created automatically. |
I think this should work #36. Are there any objections? |
@steveteuber If am trying to upgrade from 1.4.1 to 1.4.2, I got 403 error again:
On 1.4.1 all looks good. |
Hm, I thought so. Is it possible to create indices with your current credentials? |
@steveteuber Yes, I can create indices with current credentials. |
Strange, then it should be possible to create/modify the role mappings... Does anyone else have an idea? |
if I run this against my cluster endpoint it works without issues curl -XPUT -u 'admin:password' "https://production.logs.example.com/_plugins/_security/api/rolesmapping/all_access" -H 'Content-Type: application/json' -d'
{
"backend_roles" : [],
"hosts" : [],
"users" : [ "admin" ]
}' {"status":"OK","message":"'all_access' updated."} and this is basically the same the provider/module should do |
it looks like is related to this @insider89 can you try adding provider "elasticsearch" {
url = module.opensearch.cluster_endpoint
aws_region = data.aws_region.current.name
healthcheck = false
sign_aws_requests = false
username = local.admin_credentials.username
password = local.admin_credentials.password
} |
@egarbi with are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_name["all_access"] will be created
+ resource "elasticsearch_opensearch_roles_mapping" "master_user_name" {
+ id = (known after apply)
+ role_name = "all_access"
+ users = (sensitive value)
}
# module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_name["security_manager"] will be created
+ resource "elasticsearch_opensearch_roles_mapping" "master_user_name" {
+ id = (known after apply)
+ role_name = "security_manager"
+ users = (sensitive value)
}
Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_name["all_access"]: Creating...
module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_name["security_manager"]: Creating...
╷
│ Error: ElasticSearch version 2.5.0 is older than 6.0.0 and is not supported, flavor: 0.
│
│ with module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_name["security_manager"],
│ on .terraform/modules/opensearch/role_mapping.tf line 31, in resource "elasticsearch_opensearch_roles_mapping" "master_user_name":
│ 31: resource "elasticsearch_opensearch_roles_mapping" "master_user_name" {
│
╵
╷
│ Error: ElasticSearch version 2.5.0 is older than 6.0.0 and is not supported, flavor: 0.
│
│ with module.opensearch.elasticsearch_opensearch_roles_mapping.master_user_name["all_access"],
│ on .terraform/modules/opensearch/role_mapping.tf line 31, in resource "elasticsearch_opensearch_roles_mapping" "master_user_name":
│ 31: resource "elasticsearch_opensearch_roles_mapping" "master_user_name" {
│
╵
Releasing state lock. This may take a few moments... |
Not sure if related but make sure you have compatibility mode (with elasticsearch) enabled on your Amazon OpenSearch cluster. This cheats not compatible clients to believe they are speaking with an ES cluster. |
@egarbi Could you please point me where I can check it(didn't find any properties in my configurations). |
@egarbi looks like Elasticsearch terraform provider still does not support Opensearch v2, only v1. With the following workaround I am able to successfully apply v1.4.2:
|
@insider89 thanks for the feedback. |
Ok, I will close this issue for now. Thanks for your help! |
terraform apply works fine but terraform destroy showing below error
|
I am using following configuration to create opensearch cluster:
But it's failed with following error:
master_user_arn is empty, but it tries to create role_mapping for it.
The text was updated successfully, but these errors were encountered: