I want to create a bedrock agent with a knowledge base. For the knowledge base I have to use Opensearch. So, I created an opensearch serverless collection and I need to create a vector index and vector fields. I have to do it as code, so I tried to search how to create it and I found that I could only use an API call to the endpoint provided by the collection. So I tried to call the endpoint like in this guide:
[PUT] https://xyz.us-east-1.aoss.amazonaws.com/housing-index
Body:
{
"settings": {
"index.knn": true
},
"mappings": {
"properties": {
"housing-vector": {
"type": "knn_vector",
"dimension": 3
},
"title": {
"type": "text"
},
"price": {
"type": "long"
},
"location": {
"type": "geo_point"
}
}
}
}
But it returns me this error
{
"status": 403,
"request-id": "xyz",
"error": {
"reason": "403 Forbidden",
"type": "Forbidden"
}
}
So it tried to create it in the console, and it worked. Then i tried in the opensearch dashboard, and it worked. And the problem isn't the way I call the api, because I use my aws credentials in Insomnia and call it. I even has a successful response when doing this call:
https://xyz.us-east-1.aoss.amazonaws.com/index-created-in-console
And the problem isn't the permissions because I have the AdministratorAccess, and gave me all the permissions I could (Data access policies, Encryption policies, Network policies, ...).
I tried a lot of bodies: in JSON, Plain, other, ... With and without the PUT housing-index
in it.
If anyone could help me I would be grateful.