gpt4 book ai didi

amazon-web-services - 如何使用 Terraform 添加具有结构类型列的 Glue Table?

转载 作者:行者123 更新时间:2023-12-05 05:09:52 27 4
gpt4 key购买 nike

我正在启用 Athena 以使用 Terraform 查询 Cloudtrail s3 日志。为此,我需要在 Glue Catalog 中创建数据库和表。我正在关注这个 link .

在 Terraform 中,我使用 aws_glue_catalog_table 资源。如何在 terraform 文件中定义类型为 struct 和 Array 的列?

我尝试定义以下方式,但没有成功。

  resource "aws_glue_catalog_database" "cloud_logs" {
name = "trail_logs_db"
}

resource "aws_glue_catalog_table" "cloud_table" {
name = "trail_logs"
database_name = "${aws_glue_catalog_database.cloud_logs.name}"

table_type = "EXTERNAL_TABLE"

parameters = {
EXTERNAL = "TRUE"
}

storage_descriptor {
location = "s3://<BUCKET NAME>/AWSLogs/<AWS ACCOUNT ID>/"
input_format = "com.amazon.emr.cloudtrail.CloudTrailInputFormat"
output_format = "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"

ser_de_info {
name = "trail-logs"
serialization_library = "com.amazon.emr.hive.serde.CloudTrailSerde"

parameters {
serialization.format = 1
}
}

columns = [
{
name = "useridentity"
type = "struct<type:string,
principalid:string,
arn:string,
accountid:string,
invokedby:string,
accesskeyid:string,
userName:string,>"
comment = ""
},
{
name = "resources"
type = "array<STRUCT<ARN:string,
accountId:string,
type:string>>"
comment = ""
},
]
}
}

当我运行 terraform init 它抛出以下错误:错误:解析 test.tf 时出错:在 33:27:非法字符

最佳答案

找到解决方法,但看起来不太好。

当我将其格式化为一行时,它会起作用。

  {
name = "useridentity"
type = "struct<type:string, principalid:string, arn:string, accountid:string, invokedby:string, accesskeyid:string, userName:string,>"
comment = ""
},
{
name = "resources"
type = "array<STRUCT<ARN:string, accountId:string, type:string>>"
comment = ""
},

关于amazon-web-services - 如何使用 Terraform 添加具有结构类型列的 Glue Table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57141147/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com