Open david-alpert-nl opened 1 year ago
from what I can tell I think this resourceOpensearchIndexRead(...)
method is missing the mappings on import as it never explicitly gets them from the opensearch client:
https://github.com/opensearch-project/terraform-provider-opensearch/blob/08ca809a1111164e3d8a2fa2d3bfd1ea11700a29/provider/resource_opensearch_index.go#L701-L765
the osClient.IndexGetSettings
call uses the /{index}/_settings
endpoint which does not return mappings, for example:
{
"my-index": {
"settings": {
"index": {
"creation_date": "1692630469965",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "M6a4_T9QSJ-EkydkCouCAg",
"version": {
"created": "136267827"
},
"provided_name": "my-index"
}
}
}
}
I think the provider read
method also needs to call the osClient.GetMapping(index)
method which uses the/{index}/_mapping/
endpoint to import the existing mapping.
{
"my-index": {
"mappings": {
"properties": {
...
}
}
}
}
If I am on the right track I am happy to submit a pull request.
I wonder now if this is an issue with API differences?
it appears that OpenSearch 2.9 exposes a more complete response at the GET /{index}
endpoint that includes both mappings and settings, perhaps shaped more like this provider code expects 🤔
@phillbaker , @prudhvigodithi , would you pls help take a look and comment ?
@david-alpert-nl , thanks for reporting the issue and share the finding ,,, would you mind also create a Pull Request for the team here to review and discuss ? thanks again !
Thanks @david-alpert-nl, to the provider Read
operation we should be adding a condition osClient.GetMapping(index) method, please open a pull request when you are ready, Thanks
Adding @phillbaker @bbarani @peterzhuamazon
Thank you
What is the bug?
The
opensearch_index
resource does not seem to store or manage themappings
property.How can one reproduce the bug?
opensearch
provider with valid connection (e.g. url, credentials, etc) to an existing OpenSearch server with a valid index containing mappings.opensearch_index
resource with a mappingWhat is the expected behavior?
What is the actual behavior?
What is your host/environment?
Do you have any additional context?