Closed jlustin closed 1 month ago
Hey @jlustin I assume you are using the latest version of the provider https://registry.terraform.io/providers/opensearch-project/opensearch/2.0.0 In this comment I have tested creating index and index template and able to create and destroy, please check https://github.com/opensearch-project/terraform-provider-opensearch/issues/72#issuecomment-1714363935 Adding @rblcoder @afrodidact @premkirank Thank you
@prudhvigodithi I would like to work on this
Thanks assigned to your @premkirank.
I am starting on this issue from now. Had been working on some minor bugs etc to get a hang of the repo. Sorry for the delay
@jlustin I have been able to follow along until step 2 and been able to verify what you have said. I am not able to understand step 3 i.e deleting an index module. How can I delete an index module, is there some API for this?
Hey @jlustin as per the discussion here https://github.com/opensearch-project/terraform-provider-opensearch/issues/83#issuecomment-1787722531, the index should not get deleted when configured an alias using the provider? Can you please confirm if you are using the latest version? Thanks
@premkirank Thanks for the update. For step 3, I just meant deleting the config of the index from the files
@prudhvigodithi This was initially produced when using registry.terraform.io/opensearch-project/opensearch v1.0.0
as specified above; I will try once more after doing an update
Hi both, I'm using v2.1.0 now and seeing the same behavior as initially described.
@prudhvigodithi This is the output when I try modifying the alias of an index via the provider; the index would get replaced:
@premkirank Thanks for the update. For step 3, I just meant deleting the config of the index from the files
@jlustin could you just provide a sample for this file after deleting the config. It will help make it clear.
HI @premkirank : can you please start by the first step (Set aliases for the index. The index will get destroyed and recreated.) Is that a normal behavior ? Adding an alias to an index should not force recreating the index.
HI @premkirank @prudhvigodithi Is there any update on the above bug when it will be fixed? Adding an alias to the existing index the index gets deleted :(
Hey @anuborah thanks for sharing your thoughts, I agree this bug has to be fixed, we can looking for some contributors, is it possible for you to fix this bug by creating a PR? I'm happy to help and troubleshoot here. We can talk more in this slack channel as well https://opensearch.slack.com/archives/C051ZNQ16KG. Thank you Adding @imanis @jlustin @premkirank @rblcoder @getsaurabh02
I have a PR open for this bug https://github.com/opensearch-project/terraform-provider-opensearch/pull/212, we can now update the aliases
section on existing opensearch_index
without destroying or force update.
aliases = jsonencode(
{
"log": {
"is_write_index": true
}
}
)
Example output when the index is created with no aliases
curl http://localhost:9200/sample/_alias -u 'admin:myStrongPassword123@456' | jq '.'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 25 100 25 0 0 8389 0 --:--:-- --:--:-- --:--:-- 12500
{
"sample": {
"aliases": {}
}
}
Example terraform apply output when the index is created and aliases is added
# opensearch_index.index will be updated in-place
~ resource "opensearch_index" "index" {
+ aliases = jsonencode(
{
+ log = {
+ is_write_index = true
}
}
)
id = "sample"
name = "sample"
# (4 unchanged attributes hidden)
}
curl http://localhost:9200/sample/_alias -u 'admin:myStrongPassword123@456' | jq '.'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 54 100 54 0 0 19244 0 --:--:-- --:--:-- --:--:-- 27000
{
"sample": {
"aliases": {
"log": {
"is_write_index": true
}
}
}
}
Thanks @getsaurabh02
Hey @jlustin the index cannot be deleted if the documents are present thats the behavior of the OpenSearch and nothing to do with the terraform provider.
The terraform provider 2.3.1 is released with opensearch_index
aliases
bug fix, @anuborah @imanis @jlustin please take a look.
Thanks
Closing this issue since the terraform provider 2.3.1 is released with opensearch_index
aliases bug fix, please feel free to add a comment or re-open if required.
Thank you
@getsaurabh02
What is the bug?
Hi, I am currently looking at ways to delete an index and the behavior I am seeing when modifying a opensearch_index resource is very confusing.
aliases
of an existing index, the index gets destroyed then recreated by Terraform, logs saying that the index must be replaced, in which case the index is destroyed and recreated. However, when modifying other attributes such asnumber_of_replicas
orrefresh_interval
, the index gets updated in place and the index is kept.force_destroy
totrue
or flicking it fromfalse
totrue
, Terraform indicates in the plan that the index is changed, but does not actually destroy the index.Provider configuration not present
. This also happens whether I delete the targeted index manually from the OS dashboard or not; so if I delete the index manually and do not remove the module, the index will get recreated, and if I remove the module, I get that error. I am able to get through this stage by doing astate rm
on the module, but this does not actually delete the index either.How can one reproduce the bug?
Create an index without
aliases
norforce_destroy
:aliases
for the index. The index will get destroyed and recreated.force_destroy
totrue
. Nothing happens to the index.What is the expected behavior?
What is your host/environment?
Do you have any additional context?
Context = I am seeing this behavior when trying to delete an index. What would be the correct way to achieve deleting an index that was created using the terraform provider? Is this supported somehow?