hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 8.99k forks source link

[Bug]: aws_opensearchserverless_collection got AutoFlEx error #38138

Open takenakasuji-rhcapital opened 2 days ago

takenakasuji-rhcapital commented 2 days ago

Terraform Core Version

1.8.5

AWS Provider Version

5.55.0

Affected Resource(s)

aws_opensearchserverless_collection

Expected Behavior

OpenSearch correction is imported successfully.

Actual Behavior

Error occurring when running terraform plan.

Relevant Error/Panic Output Snippet

╷
│ Error: AutoFlEx
│ 
│ does not implement attr.Value: struct
╵
╷
│ Error: AutoFlEx
│ 
│ Flatten[*types.CollectionDetail, *opensearchserverless.resourceCollectionData]
╵

Terraform Configuration Files

import {
  to = module.open_search.aws_opensearchserverless_security_policy.encryption
  id = "example/encryption"
}

import {
  to = module.open_search.aws_opensearchserverless_collection.this
  id = "example"
}

resource "aws_opensearchserverless_security_policy" "encryption" {
  name        = "example"
  type        = "encryption"
  description = "example"
  policy = jsonencode({
    Rules = [
      {
        ResourceType = "collection"
        Resource = [
          "collection/example"
        ],
      }
    ],
    AWSOwnedKey = true
  })
}

resource "aws_opensearchserverless_collection" "this" {
  name       = "example"
  type       = "SEARCH"
  depends_on = [aws_opensearchserverless_security_policy.encryption]
}

Steps to Reproduce

A simple terraform plan.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 2 days ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

GrayIbis commented 1 day ago

Hello - I'm not sure if this is the same issue I had but I was getting same error with 5.55.0 so I went back to previous working version 5.31.0 and different error message was generated pointing me to resolution ( permission )

5.55.0: │ Error: AutoFlEx │ │   with aws_opensearchserverless_collection.documents, │   on opensearch.tf line 22, in resource "aws_opensearchserverless_collection" "documents": │   22: resource "aws_opensearchserverless_collection" "documents" { │ │ does not implement attr.Value: struct

╷ │ Error: AutoFlEx │ │ with aws_opensearchserverless_collection.documents, │ on opensearch.tf line 22, in resource "aws_opensearchserverless_collection" "documents": │ 22: resource "aws_opensearchserverless_collection" "documents" { │ │ Flatten[types.CollectionDetail, opensearchserverless.resourceCollectionData] ╵

5.31.0:

   with aws_opensearchserverless_collection.documents, │   on opensearch.tf line 22, in resource "aws_opensearchserverless_collection" "documents": │   22: resource "aws_opensearchserverless_collection" "documents" { │ │ operation error OpenSearchServerless: BatchGetCollection, https response error StatusCode: 400, RequestID: xxxxxxxxxx, api error AccessDeniedException: User: │ arn:aws:sts::xxxxx:assumed-role/xxxxx/xxxxx is not authorized to perform: aoss:BatchGetCollection on resource: │ arn:aws:aoss:xxxx:xxxxxx:collection/xxxxxx because no permissions boundary allows the aoss:BatchGetCollection action

takenakasuji-rhcapital commented 1 day ago

@GrayIbis Hello, Thank you for your information. When I reverted the version to 5.31.0 and executed it, I was able to obtain detailed error information.

takenakasuji-rhcapital commented 1 day ago

The issue with this error is that when using version 5.55.0, the detailed error returned from AWS is not being displayed.