【问题标题】:Step Function definition in Terraform (Yaml)Terraform (Yaml) 中的阶跃函数定义
【发布时间】:2021-07-14 15:38:43
【问题描述】:

我已经在 Terraform (JSON) 文件中实现了 SFn:

data "template_file" "sfn-definition" {
  template = file("step-function-definition.json")
}

resource "aws_sfn_state_machine" "sfn_state_machine" {
   name = "integration-step-function"
   role_arn = aws_iam_role.step_function_role.arn
   definition = data.template_file.sfn-definition.rendered
}

它工作正常,但我想使用 YAML 定义而不是 JSON。 我在 YAML 中创建了相同的 SFn 定义。我在 AWS Toolkit (VS Code) 中完成了它,并且图形正确呈现。我将 JSON 文件更改为 YAML:

template = file("step-function-definition.yaml")

不幸的是,它不起作用:

08:58:39  Error: Error creating Step Function State Machine: InvalidDefinition: 
Invalid State Machine Definition: 'INVALID_JSON_DESCRIPTION: 
Unrecognized token 'StartAt': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

我想aws_sfn_state_machine 中的definition 需要 JSON 文件,但是有没有任何选项可以在 YAML 中定义 SFn 并使用 Terraform?

【问题讨论】:

    标签: amazon-web-services terraform aws-step-functions


    【解决方案1】:

    Amazon States Language基于 JSON 的。所以你必须先将你的 yaml 转换为 json。您可以尝试以下方法:

    template = jsonencode(yamldecode(file("step-function-definition.yaml")))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-25
      • 1970-01-01
      相关资源
      最近更新 更多