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

kendra_index getting replaced on failed kendra_faq re-deployment #1562

Closed
quixoticmonk opened this issue Apr 17, 2024 · 9 comments
Closed

kendra_index getting replaced on failed kendra_faq re-deployment #1562

quixoticmonk opened this issue Apr 17, 2024 · 9 comments
Assignees

Comments

@quixoticmonk
Copy link
Collaborator

quixoticmonk commented Apr 17, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Terraform CLI and Terraform AWS Cloud Control Provider Version

terraform --version
Terraform v1.7.4

terraform {
  required_providers {
    awscc = {
      source  = "hashicorp/awscc"
      version = "0.74.0"
    }
  }
}

Affected Resource(s)

  • awscc_kendra_index
  • awscc_kendra_faq

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "awscc_kendra_faq" "example" {
  index_id = awscc_kendra_index.example.id
  name     = "Example"
  role_arn = awscc_iam_role.faq.arn

  s3_path = {
    bucket = var.bucket_name
    key    = var.faq_key
  }

  description   = "Example of Kendra FAQ"
  file_format   = "CSV_WITH_HEADER" # was set to CSV originally and deployment failed. 
  language_code = "en"

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
}

resource "awscc_iam_role" "faq" {
  role_name   = "kendra_faq_role"
  description = "Role used for Kendra FAQs"
  assume_role_policy_document = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Principal = {
          Service = "kendra.amazonaws.com"
        }
      }
    ]
  })
  tags = [
    {
      key   = "Name"
      value = "Kendra FAQ role"
    },
    {
      key   = "Modified By"
      value = "AWSCC"
    }
  ]
}

variable "bucket_name" {
  type        = string
  description = "S3 Bucket holding the FAQ documents"
  default = "manuchn-tftest-bucket"
}

variable "faq_key" {
  type        = string
  description = "Bucket key for the FAQ document"
  default = "faqs.csv"
}

resource "awscc_iam_role_policy" "faq_policy" {
  policy_name = "kendra_faq_role_policy"
  role_name   = awscc_iam_role.faq.id

  policy_document = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect   = "Allow"
        Action   = "s3:GetObject"
        Resource = "arn:aws:s3:::${var.bucket_name}/*"
      },

      {
        Effect   = "Allow"
        Action   = "kms:Decrypt",
        Resource = "arn:aws:kms:us-east-1:${data.aws_caller_identity.current.account_id}:key/*",
        Condition = {
          "StringLike" : {
            "kms:ViaService" : "kendra.us-east-1.amazonaws.com"
          }
        }
      },

    ]
  })
}

resource "awscc_kendra_index" "example" {
  edition     = "ENTERPRISE_EDITION"
  name        = "example-index"
  role_arn    = awscc_iam_role.example.arn
  description = "Example Kendra index"

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
}

resource "awscc_iam_role" "example" {
  role_name   = "kendra_index_role"
  description = "Role assigned to the Kendra index"
  assume_role_policy_document = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Principal = {
          Service = "kendra.amazonaws.com"
        }
      }
    ]
  })
  max_session_duration = 7200
  tags = [
    {
      key   = "Name"
      value = "Kendra index role"
    },
    {
      key   = "Modified By"
      value = "AWSCC"
    }
  ]
}

resource "awscc_iam_role_policy" "example" {
  policy_name = "kendra_role_policy"
  role_name   = awscc_iam_role.example.id

  policy_document = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Effect   = "Allow"
        Action   = "cloudwatch:PutMetricData"
        Resource = "*"
        Condition = {
          "StringEquals" : {
            "cloudwatch:namespace" : "AWS/Kendra"
          }
        }
      },
      {
        Effect   = "Allow"
        Action   = "logs:DescribeLogGroups"
        Resource = "*"
      },
      {
        Effect   = "Allow"
        Action   = "logs:CreateLogGroup",
        Resource = "arn:aws:logs:us-east-1:${data.aws_caller_identity.current.account_id}:log-group:/aws/kendra/*"
      },
      {
        Effect = "Allow"
        Action = [
          "logs:DescribeLogStreams",
          "logs:CreateLogStream",
          "logs:PutLogEvents"
        ],
        Resource = "arn:aws:logs:us-east-1:${data.aws_caller_identity.current.account_id}:log-group:/aws/kendra/*:log-stream:*"
      }
    ]
  })
}

data "aws_caller_identity" "current" {}

Debug Output

Panic Output

Expected Behavior

  • Kendra index is created
  • Kendra FAQ is created and associated with the Kendra index created above.

Actual Behavior

  • Kendra index is created
  • Kendra FAQ is created and associated with the Kendra index created above.
  • Kendra FAQ is in failed status and Terraform shows the below error message.
awscc_kendra_index.example: Still creating... [19m10s elapsed]
awscc_kendra_index.example: Still creating... [19m20s elapsed]
awscc_kendra_index.example: Creation complete after 19m24s [id=0134506d-7b44-4ff5-938e-7e3b942d6751]
awscc_kendra_faq.example: Creating...
awscc_kendra_faq.example: Still creating... [10s elapsed]
╷
│ Error: AWS SDK Go Service Operation Incomplete
│
│   with awscc_kendra_faq.example,
│   on main.tf line 1, in resource "awscc_kendra_faq" "example":
│    1: resource "awscc_kendra_faq" "example" {
│
│ Waiting for Cloud Control API service CreateResource operation completion
│ returned: waiter state transitioned to FAILED. StatusMessage: Resource of type
│ 'AWS::Kendra::Faq' with identifier '7da886a0-8c9d-4d96-adc3-1f8968326978' did
│ not stabilize.. ErrorCode: NotStabilized

[! IMPORTANT]
awscc_kendra_index.example is created as part of the process here.

  • On re-applying or re-planning, the Terraform plan identifies changes in the Kendra index and attempts to destroy/recreate and is stuck.
    • Note that there was no change done in the Kendra index configuration between the FAQ failure and re-apply
Terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # awscc_iam_role.example will be updated in-place
  ~ resource "awscc_iam_role" "example" {
        id                          = "kendra_index_role"
      + managed_policy_arns         = (known after apply)
      + permissions_boundary        = (known after apply)
        tags                        = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
            {
                key   = "Name"
                value = "Kendra index role"
            },
        ]
        # (8 unchanged attributes hidden)
    }

  # awscc_iam_role.faq will be updated in-place
  ~ resource "awscc_iam_role" "faq" {
        id                          = "kendra_faq_role"
      + managed_policy_arns         = (known after apply)
      + permissions_boundary        = (known after apply)
        tags                        = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
            {
                key   = "Name"
                value = "Kendra FAQ role"
            },
        ]
        # (8 unchanged attributes hidden)
    }

  # awscc_kendra_faq.example is tainted, so must be replaced
-/+ resource "awscc_kendra_faq" "example" {
      ~ arn           = "arn:aws:kendra:us-east-1:###########:index/0134506d-7b44-4ff5-938e-7e3b942d6751/faq/7da886a0-8c9d-4d96-adc3-1f8968326978" -> (known after apply)
      ~ faq_id        = "7da886a0-8c9d-4d96-adc3-1f8968326978" -> (known after apply)
      ~ id            = "7da886a0-8c9d-4d96-adc3-1f8968326978|0134506d-7b44-4ff5-938e-7e3b942d6751" -> (known after apply)
      ~ index_id      = "0134506d-7b44-4ff5-938e-7e3b942d6751" -> (known after apply)
        name          = "Example"
        tags          = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
        ]
        # (5 unchanged attributes hidden)
    }

  # awscc_kendra_index.example must be replaced
-/+ resource "awscc_kendra_index" "example" {
      ~ arn                                  = "arn:aws:kendra:us-east-1:###########:index/0134506d-7b44-4ff5-938e-7e3b942d6751" -> (known after apply)
      + capacity_units                       = (known after apply)
      ~ document_metadata_configurations     = [
          - {
              - name      = "_authors" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = false -> null
                } -> null
              - type      = "STRING_LIST_VALUE" -> null
            },
          - {
              - name      = "_category" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_created_at" -> null
              - relevance = {
                  - duration   = "25920000s" -> null
                  - freshness  = false -> null
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "DATE_VALUE" -> null
            },
          - {
              - name      = "_data_source_id" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_document_title" -> null
              - relevance = {
                  - importance = 2 -> null
                } -> null
              - search    = {
                  - displayable = true -> null
                  - facetable   = false -> null
                  - searchable  = true -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_excerpt_page_number" -> null
              - relevance = {
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = false -> null
                } -> null
              - type      = "LONG_VALUE" -> null
            },
          - {
              - name      = "_faq_id" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_file_type" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_language_code" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_last_updated_at" -> null
              - relevance = {
                  - duration   = "25920000s" -> null
                  - freshness  = false -> null
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "DATE_VALUE" -> null
            },
          - {
              - name      = "_source_uri" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = true -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = false -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_tenant_id" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_version" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_view_count" -> null
              - relevance = {
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "LONG_VALUE" -> null
            },
        ] -> (known after apply)
      ~ id                                   = "0134506d-7b44-4ff5-938e-7e3b942d6751" -> (known after apply)
      ~ index_id                             = "0134506d-7b44-4ff5-938e-7e3b942d6751" -> (known after apply)
        name                                 = "example-index"
      + server_side_encryption_configuration = (known after apply) # forces replacement
        tags                                 = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
        ]
      ~ user_context_policy                  = "ATTRIBUTE_FILTER" -> (known after apply)
      + user_token_configurations            = (known after apply)
        # (3 unchanged attributes hidden)
    }

Plan: 2 to add, 2 to change, 2 to destroy.

Steps to Reproduce

  1. terraform apply
  2. Review the failure and perform another terraform apply with the changes to original failed FAQ ( CSV to CSV_CSV_WITH_HEADER)

Important Factoids

References

  • #0000
@quixoticmonk
Copy link
Collaborator Author

This is happening with kendra_data_source as well.

Steps to reproduce:

  1. Create a Kendra index and Kendra datasource ( custom)
  2. Comment the datasource and re-apply.
  3. Apply is forcing a replacement of the index which shouldn't be part of this operation.
Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  ~ update in-place
  - destroy
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # awscc_iam_role.example will be updated in-place
  ~ resource "awscc_iam_role" "example" {
        id                          = "kendra_index_role"
      + managed_policy_arns         = (known after apply)
      + permissions_boundary        = (known after apply)
        tags                        = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
            {
                key   = "Name"
                value = "Kendra index role"
            },
        ]
        # (8 unchanged attributes hidden)
    }

  # awscc_kendra_data_source.example will be destroyed
  # (because awscc_kendra_data_source.example is not in configuration)
  - resource "awscc_kendra_data_source" "example" {
      - arn            = "arn:aws:kendra:us-east-1:###########:index/b579a25c-02e7-4736-8d4e-726df3f7e7fd/data-source/80e39610-fd7a-4f37-9f68-46844be772ea" -> null
      - data_source_id = "80e39610-fd7a-4f37-9f68-46844be772ea" -> null
      - description    = "example" -> null
      - id             = "80e39610-fd7a-4f37-9f68-46844be772ea|b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> null
      - index_id       = "b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> null
      - language_code  = "en" -> null
      - name           = "example" -> null
      - tags           = [
          - {
              - key   = "Modified By" -> null
              - value = "AWSCC" -> null
            },
        ] -> null
      - type           = "CUSTOM" -> null
    }

  # awscc_kendra_index.example must be replaced
-/+ resource "awscc_kendra_index" "example" {
      ~ arn                                  = "arn:aws:kendra:us-east-1:###########:index/b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> (known after apply)
      + capacity_units                       = (known after apply)
      ~ document_metadata_configurations     = [
          - {
              - name      = "_authors" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = false -> null
                } -> null
              - type      = "STRING_LIST_VALUE" -> null
            },
          - {
              - name      = "_category" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_created_at" -> null
              - relevance = {
                  - duration   = "25920000s" -> null
                  - freshness  = false -> null
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "DATE_VALUE" -> null
            },
          - {
              - name      = "_data_source_id" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_document_title" -> null
              - relevance = {
                  - importance = 2 -> null
                } -> null
              - search    = {
                  - displayable = true -> null
                  - facetable   = false -> null
                  - searchable  = true -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_excerpt_page_number" -> null
              - relevance = {
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = false -> null
                } -> null
              - type      = "LONG_VALUE" -> null
            },
          - {
              - name      = "_faq_id" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_file_type" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_language_code" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_last_updated_at" -> null
              - relevance = {
                  - duration   = "25920000s" -> null
                  - freshness  = false -> null
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "DATE_VALUE" -> null
            },
          - {
              - name      = "_source_uri" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = true -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = false -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_tenant_id" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_version" -> null
              - relevance = {
                  - importance = 1 -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "STRING_VALUE" -> null
            },
          - {
              - name      = "_view_count" -> null
              - relevance = {
                  - importance = 1 -> null
                  - rank_order = "ASCENDING" -> null
                } -> null
              - search    = {
                  - displayable = false -> null
                  - facetable   = false -> null
                  - searchable  = false -> null
                  - sortable    = true -> null
                } -> null
              - type      = "LONG_VALUE" -> null
            },
        ] -> (known after apply)
      ~ id                                   = "b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> (known after apply)
      ~ index_id                             = "b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> (known after apply)
        name                                 = "example-index"
      + server_side_encryption_configuration = (known after apply) # forces replacement
        tags                                 = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
        ]
      ~ user_context_policy                  = "ATTRIBUTE_FILTER" -> (known after apply)
      + user_token_configurations            = (known after apply)
        # (3 unchanged attributes hidden)
    }

Plan: 1 to add, 1 to change, 2 to destroy.

@wellsiau-aws
Copy link
Collaborator

I believe the problem with Kendra FAQ is upstream AWS.

awscc_kendra_faq.example: Creating...
awscc_kendra_faq.example: Still creating... [10s elapsed]
╷
│ Error: AWS SDK Go Service Operation Incomplete
│
│   with awscc_kendra_faq.example,
│   on main.tf line 1, in resource "awscc_kendra_faq" "example":
│    1: resource "awscc_kendra_faq" "example" {
│
│ Waiting for Cloud Control API service CreateResource operation completion
│ returned: waiter state transitioned to FAILED. StatusMessage: Resource of type
│ 'AWS::Kendra::Faq' with identifier '7da886a0-8c9d-4d96-adc3-1f8968326978' did
│ not stabilize.. ErrorCode: NotStabilized

thanks for reporting this, we'll investigate this separately.

@wellsiau-aws
Copy link
Collaborator

From inspecting the execution plan, there's one particular attribute (server_side_encryption_configuration) that I suspect causing the problem

  # awscc_kendra_index.example must be replaced
-/+ resource "awscc_kendra_index" "example" {
      ~ arn                                  = "arn:aws:kendra:us-east-1:###########:index/b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> (known after apply)
      + capacity_units                       = (known after apply)
      ~ document_metadata_configurations     = [
         . . .
        ] -> (known after apply)
      ~ id                                   = "b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> (known after apply)
      ~ index_id                             = "b579a25c-02e7-4736-8d4e-726df3f7e7fd" -> (known after apply)
        name                                 = "example-index"
      + server_side_encryption_configuration = (known after apply) # forces replacement
        tags                                 = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
        ]
      ~ user_context_policy                  = "ATTRIBUTE_FILTER" -> (known after apply)
      + user_token_configurations            = (known after apply)
        # (3 unchanged attributes hidden)
    }

@wellsiau-aws
Copy link
Collaborator

@quixoticmonk ,

Could you please share your Terraform state file for resource awscc_kendra_index.example , attribute name: server_side_encryption_configuration. I suspect that you found it shown as null in the Terraform state file.

@wellsiau-aws
Copy link
Collaborator

likely relates to #1139

@quixoticmonk
Copy link
Collaborator Author

It is.

"edition": "ENTERPRISE_EDITION",
            "id": "0ca95efb-cfa9-42b2-82c7-7401ada4ef31",
            "index_id": "0ca95efb-cfa9-42b2-82c7-7401ada4ef31",
            "name": "example-index",
            "role_arn": "arn:aws:iam::######:role/kendra_index_role",
            "server_side_encryption_configuration": null,
            "tags": [
              {
                "key": "Modified By",
                "value": "AWSCC"
              }
            ],

@wellsiau-aws
Copy link
Collaborator

On my recent test with provider AWSCC 1.2.0 , I saw that the behavior has changed a bit.

Terraform plan is no longer triggering replacement, I believe thanks to the fix on #1712, however it still detecting drift

  # awscc_kendra_index.example will be updated in-place
  ~ resource "awscc_kendra_index" "example" {
      + capacity_units                       = (known after apply)
        id                                   = "7f069663-4368-44fd-8ac4-745dd11cf43e"
        name                                 = "example-index"
      + server_side_encryption_configuration = (known after apply)
        tags                                 = [
            {
                key   = "Modified By"
                value = "AWSCC"
            },
        ]
      + user_token_configurations            = (known after apply)
        # (7 unchanged attributes hidden)
    }

Debug log is telling interesting story:

2024-06-28T16:19:25.641-0700 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5: Detected value change between proposed new state and prior state: tf_attribute_path=document_metadata_configurations tf_resource_type=awscc_kendra_index @caller=github.com/hashicorp/[email protected]/internal/fwserver/server_planresourcechange.go:208 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=53bfe62c-85b6-711c-0b02-0c0640c47c83 tf_rpc=PlanResourceChange @module=sdk.framework timestamp=2024-06-28T16:19:25.641-0700

Attribute in question: document_metadata_configurations

@wellsiau-aws
Copy link
Collaborator

The remaining problem in this issue is now more relevant to problem discussed in #1216.

Further debug logs:

PlanResourceChange_Request_PriorState

{
  "arn": "arn:aws:kendra:us-east-1:204034886740:index/7f069663-4368-44fd-8ac4-745dd11cf43e",
  "capacity_units": null,
  "description": "Example Kendra index",
  "document_metadata_configurations": [
    {
      "name": "_authors",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": false
      },
      "type": "STRING_LIST_VALUE"
    },
    {
      "name": "_category",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_created_at",
      "relevance": {
        "duration": "25920000s",
        "freshness": false,
        "importance": 1,
        "rank_order": "ASCENDING",
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "DATE_VALUE"
    },
    {
      "name": "_data_source_id",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_document_title",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 2,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": true,
        "facetable": false,
        "searchable": true,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_excerpt_page_number",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": "ASCENDING",
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": false
      },
      "type": "LONG_VALUE"
    },
    {
      "name": "_faq_id",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_file_type",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_language_code",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_last_updated_at",
      "relevance": {
        "duration": "25920000s",
        "freshness": false,
        "importance": 1,
        "rank_order": "ASCENDING",
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "DATE_VALUE"
    },
    {
      "name": "_source_uri",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": true,
        "facetable": false,
        "searchable": false,
        "sortable": false
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_tenant_id",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_version",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": null,
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "STRING_VALUE"
    },
    {
      "name": "_view_count",
      "relevance": {
        "duration": null,
        "freshness": null,
        "importance": 1,
        "rank_order": "ASCENDING",
        "value_importance_items": null
      },
      "search": {
        "displayable": false,
        "facetable": false,
        "searchable": false,
        "sortable": true
      },
      "type": "LONG_VALUE"
    }
  ],
  "edition": "ENTERPRISE_EDITION",
  "id": "7f069663-4368-44fd-8ac4-745dd11cf43e",
  "index_id": "7f069663-4368-44fd-8ac4-745dd11cf43e",
  "name": "example-index",
  "role_arn": "arn:aws:iam::204034886740:role/kendra_index_role",
  "server_side_encryption_configuration": null,
  "tags": [
    {
      "key": "Modified By",
      "value": "AWSCC"
    }
  ],
  "user_context_policy": "ATTRIBUTE_FILTER",
  "user_token_configurations": null
}

PlanResourceChange_Request_ProposedNewState

Notice the attribute document_metadata_configurations is now showing null.

{
  "arn": "arn:aws:kendra:us-east-1:204034886740:index/7f069663-4368-44fd-8ac4-745dd11cf43e",
  "capacity_units": null,
  "description": "Example Kendra index",
  "document_metadata_configurations": null,
  "edition": "ENTERPRISE_EDITION",
  "id": "7f069663-4368-44fd-8ac4-745dd11cf43e",
  "index_id": "7f069663-4368-44fd-8ac4-745dd11cf43e",
  "name": "example-index",
  "role_arn": "arn:aws:iam::204034886740:role/kendra_index_role",
  "server_side_encryption_configuration": null,
  "tags": [
    {
      "key": "Modified By",
      "value": "AWSCC"
    }
  ],
  "user_context_policy": "ATTRIBUTE_FILTER",
  "user_token_configurations": null
}

@wellsiau-aws
Copy link
Collaborator

@quixoticmonk , the original issue (force replacement) has been resolved, I would like to continue the discussion on the remaining issue at #1795 to keep the discussion separate. As such, I am going to go ahead and close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants