amazon-web-services - CDK 传递步骤:如何在输入对象的根目录添加属性
问题描述
我想向输入数据的根目录添加一些属性。假设我们有
{
"f1": 1,
"cx": {
"cxf1": 113,
"cxf2": "f23"
},
"cx2": {
"cxf12": 11,
"cxf22": "f2"
}
}
我想创建 CDK Pass 步骤以将简单值和复杂值添加到输入的根并进一步传递组合数据。我应该有输出:
{
"f1": 1,
"cx": {
"cxf1": 113,
"cxf2": "f23"
},
"cx2": {
"cxf12": 11,
"cxf22": "f2"
},
"out1": "simple",
"out2complex": {
"f1A": 111,
"f2A": "f22"
}
}
我尝试了 inputPath、outputhPath、resultpath 的 Whatevr 组合不起作用。它仅在指定结果路径时才有效,并且我的结果将作为复杂元素进入路径。
我认为这是设计使然。如果我只指定 result,这意味着它将覆盖输入。
有没有办法将简单属性和复杂属性添加到输入对象的根并进一步传递?
解决方案
我们需要将 pass 步骤的输出传递给resultPath
可以说通过步骤输出是一个字符串simple
,它将被附加到现有的输入 Json 与out1
键resultPath: "$.out1"
const firstStep = new stepfunctions.Pass(this, "Build Out1", {
result: stepfunctions.Result.fromString("simple"),
resultPath: "$.out1",
});
const secondStep = new stepfunctions.Pass(this, "Build out2complex", {
result: stepfunctions.Result.fromObject({
f1A: 111,
f2A: "f22",
}),
resultPath: "$.out2complex",
});
const def = firstStep.next(secondStep);
new stepfunctions.StateMachine(this, "StateMachine", {
definition: def,
});
输入:
{
"f1": 1,
"cx": {
"cxf1": 113,
"cxf2": "f23"
},
"cx2": {
"cxf12": 11,
"cxf22": "f2"
}
}
输出:
{
"f1": 1,
"cx": {
"cxf1": 113,
"cxf2": "f23"
},
"cx2": {
"cxf12": 11,
"cxf22": "f2"
},
"out1": "simple",
"out2complex": {
"f1A": 111,
"f2A": "f22"
}
}
推荐阅读
- oracle - searching in CLOB for words in a list/table
- python - AttributeError:模块 'google.cloud' 没有属性 'logging' Google Cloud
- scala - How to print the sign %?
- swift - 如何从更高的闭包级别访问隐含的闭包参数
- python - 如何在 Django 中使用带有过滤器的多个注释?
- django - Django Trailing Slash 抛出 404
- python - Python AWS Lambda 部署 - 没有 Zappa 要求的 Zappa 包
- swift - 仅具有特定捆绑标识符的框架未找到错误
- python - Codechef ORMATRIX
- php - php将int乘以十进制产生一个int?