Skip to content
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] Whitespace formatting change forces redeployment of index #237

Open
richarda23 opened this issue Feb 13, 2025 · 0 comments
Open

[BUG] Whitespace formatting change forces redeployment of index #237

richarda23 opened this issue Feb 13, 2025 · 0 comments
Labels
bug Something isn't working untriaged

Comments

@richarda23
Copy link

richarda23 commented Feb 13, 2025

What is the bug?

Hello, I am attempting to deploy an AWS Bedrock knowledgebase stack using an OpenSearch Serverless backing store.

If I deploy the stack first time, it runs fine.
IF I run deploy again, having made no changes, I get message saying a whitespace change forces redeployment. I definitely don't want this; if the index contains data the replacement will fail, and anyway I don't want it replaced.

Thanks i.a for any guidance or suggestions!

 # opensearch_index.bedrock-tf_opensearchIndex_2C121812 (bedrock-tf/opensearchIndex) must be replaced
                     -/+ resource "opensearch_index" "bedrock-tf_opensearchIndex_2C121812" {
                           ~ id                             = "bedrock-knowledge-base-default-index" -> (known after apply)
                           ~ mappings                       = jsonencode( # whitespace changes force replacement

How can one reproduce the bug?

Steps to reproduce the behavior.

  1. Deploy an open search index in a serverless collection. I am using CDK for Terraform, not sure if this makes any difference)
const openSearchVectorIndex = new Index(this, "opensearchIndex", {
      dependsOn: [collection],
      name: openSearchIndexConfig.indexName,
      numberOfShards: "2",
      indexKnnAlgoParamEfSearch: "512",
      indexKnn: true,
      forceDestroy: false,

      // these defaults were found by inspecting the indexes created by the Bedrock  knowledgebase 'quick start'
      mappings: JSON.stringify({
        properties: {
          [openSearchIndexConfig.vectorMappingName]: {
            type: "knn_vector",
            dimension: 1024,
            method: {
              name: "hnsw",
              engine: "faiss",
              parameters: {
                encoder: {
                  name: "sq",
                  parameters: {
                    type: "fp16",
                    clip: true,
                  },
                },
              },
              space_type: "l2",
            },
          },
          [openSearchIndexConfig.metdataMappingName]: {
            type: "text",
            index: false,
          },
          [openSearchIndexConfig.textChunkMappingName]: {
            type: "text",
            //index: true,
          },
          ["x-amz-bedrock-kb-document-page-number"]: {
            type: "long",
            //index: true,
          },
          "x-amz-bedrock-kb-source-uri": {
            fields: {
              keyword: {
                ignore_above: 256,
                type: "keyword",
              },
            },
            type: "text",
          },
          "x-amz-bedrock-kb-data-source-id": {
            fields: {
              keyword: {
                ignore_above: 256,
                type: "keyword",
              },
            },
            type: "text",
          },
          id: {
            fields: {
              keyword: {
                ignore_above: 256,
                type: "keyword",
              },
            },
            type: "text",
          },
        },
      }),
    });

What is the expected behavior?

The deployment shouldn't trigger a replacement for whitespace changes.
If this isn't possible, is it possible to document the exact expected string format so that the source can be formatted the same?
Although this issue seems small it is essentially blocking us from using Terraform to deploy the whole stack

What is your host/environment?

Mac Sonoma 14.2, Terraform 1.9.5, CDKTF 0.20.7

Do you have any screenshots?

If applicable, add screenshots to help explain your problem.

Do you have any additional context?

Add any other context about the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant