amazon-web-services - 如何在 Terraform 的 EMR 集群中将 JSON 文件分配为 STEP?
问题描述
我正在 Terraform 中构建一个 EMR 集群,并且在 STEP 参数中我想加载一个描述步骤列表的 JSON 文件。
我在我的 main.tf 中试过这个:
ressource "aws_emr" "emr" {
...
...
step = "${data.template_file.steps.rendered}"
}
data "template_file" "steps" {
template = "${file("${path.module}/steps.json")}"
}
这是 JSON 文件:
[
{
"action_on_failure" : "CONTINUE",
"name" : "step_name",
"hadoop_jar_step" : {
"jar" : "command-runner.jar",
"args" : [
"spark-submit",
"s3://mybucket/src/pyspark/script1.py",
"1",
"68465131321321",
"s3://mybucket/parquet",
"s3://mybucket/result",
"321",
"65165165468587",
"654"
]
}
}
]
但是当我这样做时,terraform plan
我得到了这个错误:
属性“step”的值不合适:需要的对象列表。
有什么问题 ?
谢谢你的帮助。
解决方案
好的,我在另一个网站上找到了解决方案,我会在这里发布,也许有一天它会对某人有所帮助
resource "aws_emr_cluster" "cluster" {
...
dynamic "step" {
for_each = jsondecode(templatefile("steps.json", {}))
content {
action_on_failure = step.value.action_on_failure
name = step.value.name
hadoop_jar_step {
jar = step.value.hadoop_jar_step.jar
args = step.value.hadoop_jar_step.args
}
}
}
...
}
因此,可以使用 JSON 文件作为 EMR 资源中步骤的源。
推荐阅读
- vba - 我可以使用 VBA 根据匹配条件过滤 Access 表单吗?
- botframework - 如何使用 BotFramework Composer 运行主动对话
- react-hook-form - react-hook-form FormContext 默认值问题
- android - 如何从当前导航路线中获取剩余路线/坐标
- jupyter - 如何在 Jupyter Lab 暗模式下使工具栏选择颜色可见?
- tensorflow - 获取特定层的输出作为测试数据的结果,而不是 keras 中的最后一层(自动编码器潜在特征)
- image - 从子文件夹中提取 .jpeg 文件并使用 SSIS 将它们放在另一个文件夹中
- react-native - 我们什么时候应该在 React Native 中使用 `accessibilityRole`?
- angular - rxJs 三个 observables,前两个响应作为第三个的参数
- r - 如何使用 ggplot2 更改堆叠条形图的顺序和配色方案?