地形 "primary workGroup could not be created"

Terraform "primary workGroup could not be created"

我正在尝试对我的 table 在亚马逊中执行查询,但我无法执行任何查询,我收到此错误消息:

Before you run your first query, you need to set up a query result location in Amazon S3.

Your query has the following error(s):

No output location provided. An output location is required either through the Workgroup result configuration setting or as an API input. (Service: AmazonAthena; Status Code: 400; Error Code: InvalidRequestException; Request ID: b6b9aa41-20af-4f4d-91f6-db997e226936)

所以我正在尝试添加工作组,但我遇到了这个问题

'Error: error creating Athena WorkGroup: InvalidRequestException: primary workGroup could not be created
{
  RespMetadata: {
    StatusCode: 400,
    RequestID: "c20801a0-3c13-48ba-b969-4e28aa5cbf86"
  },
  AthenaErrorCode: "INVALID_INPUT",
  Message_: "primary workGroup could not be created"
}
'

我的代码

resource "aws_s3_bucket" "tony" {
  bucket = "tfouh"
}


resource "aws_athena_workgroup" "primary" {
  name       = "primary"
  depends_on = [aws_s3_bucket.tony]
  configuration {
    enforce_workgroup_configuration    = false
    publish_cloudwatch_metrics_enabled = true

    result_configuration {
      output_location = "s3://${aws_s3_bucket.tony.bucket}/"

      encryption_configuration {
        encryption_option = "SSE_S3"
      }
    }
  }
}

有解决办法请教

这可能是因为您已经有 primary 工作组。因此,您不能创建一个新的同名的。如果需要,只需创建一个不同名称的工作组:

 name       = "primary2"

@Marcin 提出了一种有效的方法,但可能更接近您正在寻找的方法 import existing workgroup into the state:

terraform import aws_athena_workgroup.primary primary

一旦该州知道了已经存在的资源,它就可以制定计划并应用可能的更改。