从 AWS Step Function 的步骤输出设置资源 Arn
Setting Resource Arn from Output of step of AWS Step Function
我有一个步骤函数,我想首先获取 ECS 集群的 resourceArn,然后在该集群上调用任务。
但是,我很难一步一步地动态传递 arn。
{
"StartAt": "GetArnLambda",
"States": {
"GetArnLambda": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:AWS_ACCOUNT_ID:function:FUNCTION_NAME",
"Next": "ecs_task"
},
"ecs_task": {
"Type": "Task",
"Resource": "arn:aws:states:::ecs:runTask.sync",
"Parameters": {
"Cluster": "$.arn",
"TaskDefinition": "ecs_task_def"
},
"End": true
}
}
我从 GetArnLambda
得到输出
{
"name": "GetArnLambda",
"output": {
"arn": "arn:aws:ecs:us-east-1:AWS_ACCOUNT_ID:cluster/CLUSTER_NAME"
}
}
但这会将集群 arn 解释为“$.arn”。如何引用我刚从第一个任务收到的 arn?
Use "Parameters" field to create a collection of key-value pairs that are passed as input. The values of each can either be static values that you include in your state machine definition, or selected from either the input or the context object with a path. For key-value pairs where the value is selected using a path, the key name must end in .$.
所以我认为你需要:
"Parameters": {
"Cluster.$": "$.arn",
"TaskDefinition": "ecs_task_def"
},
我有一个步骤函数,我想首先获取 ECS 集群的 resourceArn,然后在该集群上调用任务。
但是,我很难一步一步地动态传递 arn。
{
"StartAt": "GetArnLambda",
"States": {
"GetArnLambda": {
"Type": "Task",
"Resource": "arn:aws:lambda:us-east-1:AWS_ACCOUNT_ID:function:FUNCTION_NAME",
"Next": "ecs_task"
},
"ecs_task": {
"Type": "Task",
"Resource": "arn:aws:states:::ecs:runTask.sync",
"Parameters": {
"Cluster": "$.arn",
"TaskDefinition": "ecs_task_def"
},
"End": true
}
}
我从 GetArnLambda
{
"name": "GetArnLambda",
"output": {
"arn": "arn:aws:ecs:us-east-1:AWS_ACCOUNT_ID:cluster/CLUSTER_NAME"
}
}
但这会将集群 arn 解释为“$.arn”。如何引用我刚从第一个任务收到的 arn?
Use "Parameters" field to create a collection of key-value pairs that are passed as input. The values of each can either be static values that you include in your state machine definition, or selected from either the input or the context object with a path. For key-value pairs where the value is selected using a path, the key name must end in .$.
所以我认为你需要:
"Parameters": {
"Cluster.$": "$.arn",
"TaskDefinition": "ecs_task_def"
},