json定义文件(machine_definition.json)
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Hello",
"States": {
"Hello": {
"Type": "Pass",
"Result": "Hello",
"Next": "World"
},
"World": {
"Type": "${var.test}",
"Result": "World",
"End": true
}
}
}例如,我试图在这里输入var.test。如何使json文件检测到我的变量?
以下是步骤函数的定义
module "step-functions" {
source = "terraform-aws-modules/step-functions/aws"
name = "env-${var.environment}-state-machine"
definition = file("${path.module}/machine_definition.json")
tags = var.tags
service_integrations = {
xray = {
xray = true
}
}
cloudwatch_log_group_name = "env-${var.environment}-state-machine-logGroup"
attach_policies = true
number_of_policies = 2
policies = ["arn:aws:iam::aws:policy/AmazonS3FullAccess", "arn:aws:iam::aws:policy/AWSLambda_FullAccess"]
}发布于 2022-10-20 11:39:49
变量不能以这种方式添加到文件中。为了实现您想要的,您需要使用templatefile 1内置功能。要实现这一点,您需要进行一些代码更改:
definition = templatefile("${path.module}/machine_definition.json", {
type = var.test
})然后,在JSON文件中,需要引用模板化变量(type),如下所示:
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Hello",
"States": {
"Hello": {
"Type": "Pass",
"Result": "Hello",
"Next": "World"
},
"World": {
"Type": "${type}",
"Result": "World",
"End": true
}
}
}这应该会正确地呈现文件。
https://stackoverflow.com/questions/74136082
复制相似问题