【发布时间】:2020-04-26 05:27:22
【问题描述】:
我目前正在使用 Terraform 编写多个 AWS Kinesis Data Analytics 应用程序。两个应用程序共享相同的 Kinesis 输入流,因此具有相同的架构:
resource "aws_kinesis_analytics_application" "example1" {
name = "example1"
inputs {
# SHARE THIS ATTRIBUTE VALUE WITH example2
schema {
record_columns {
mapping = "$.FIELD1"
name = "FIELD1"
sql_type = "VARCHAR(32)"
}
record_columns {
mapping = "$.FIELD2"
name = "FIELD2"
sql_type = "VARCHAR(32)"
}
record_format {
mapping_parameters {
json {
record_row_path = "$"
}
}
}
}
}
outputs {
# other attributes
schema {
record_format_type = "JSON"
}
}
code = "SQL code ...."
}
resource "aws_kinesis_analytics_application" "example2" {
name = "example2"
inputs {
# SHARE THIS ATTRIBUTE VALUE WITH example1
schema {
record_columns {
mapping = "$.FIELD1"
name = "FIELD1"
sql_type = "VARCHAR(32)"
}
record_columns {
mapping = "$.FIELD2"
name = "FIELD2"
sql_type = "VARCHAR(32)"
}
record_format {
mapping_parameters {
json {
record_row_path = "$"
}
}
}
}
}
outputs {
# Other attributes
schema {
record_format_type = "JSON"
}
}
code = "SQL code...."
}
我假设如果有可用于架构的数据源,这是可能的:
data "aws_kinesis_analytics_application_schema" "example_input" {
record_columns {
mapping = "$.FIELD1"
name = "FIELD1"
sql_type = "VARCHAR(32)"
}
record_columns {
mapping = "$.FIELD2"
name = "FIELD2"
sql_type = "VARCHAR(32)"
}
record_format {
mapping_parameters {
json {
record_row_path = "$"
}
}
}
}
resource "aws_kinesis_analytics_application" "example1" {
name = "example1"
inputs {
# Other attributes
schema = "${data.aws_kinesis_analytics_application_schema.example_input}"
}
outputs {
# other attributes
schema {
record_format_type = "JSON"
}
}
code = "SQL code ...."
}
resource "aws_kinesis_analytics_application" "example2" {
name = "example2"
inputs {
# Other attributes
schema = "${data.aws_kinesis_analytics_application_schema.example_input}"
}
outputs {
# Other attributes
schema {
record_format_type = "JSON"
}
}
code = "SQL code...."
}
但是,没有可用于此资源的此特定属性的数据源。不使用数据源,是否可以在资源之间共享如此复杂的属性?
【问题讨论】:
标签: terraform terraform-provider-aws