Amazon web services 来自Step函数的跨帐户Lambda调用

Amazon web services 来自Step函数的跨帐户Lambda调用,amazon-web-services,aws-lambda,amazon-iam,aws-step-functions,Amazon Web Services,Aws Lambda,Amazon Iam,Aws Step Functions,我在帐户A中有阶跃函数,在帐户B中有lambda。但在运行阶跃函数时,其给出: An error occurred while executing the state 'lambdaB' (entered at the event id #2). The resource belongs to a different account from the running execution. 是否有可能进行此配置。AWS Step函数不能(直接)在其他帐户中调用AWS Lambda函数 解决方法是

我在帐户A中有阶跃函数,在帐户B中有lambda。但在运行阶跃函数时,其给出:

An error occurred while executing the state 'lambdaB' (entered at the event id #2). The resource belongs to a different account from the running execution.
是否有可能进行此配置。

AWS Step函数不能(直接)在其他帐户中调用AWS Lambda函数

解决方法是调用Lambda函数,该函数对帐户B中的IAM角色调用
AssumeRole()
,然后使用返回的凭据调用帐户B中的Lambda函数


或者,使用帐户B中的API网关允许从外部源触发Lambda函数。

我们可以在步骤函数中执行类似操作:

Parameters": {
                "FunctionName": "FUNCTION_ARN",
                "Payload.$": "$"
            },
            "Resource": "arn:aws:states:::lambda:invoke"
在Lambda中,我们需要添加权限:

"Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "sid-1",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::ACCOUNT_A:root"
      },
      "Action": "lambda:InvokeFunction",
      "Resource": "FUNCTION_ARN"
    }
  ]
}

我不能投票,因为我没有足够的声望点。我想说,step函数可以以不同的方式调用lambda,正如“AWS_Developer”所回答的那样。我们不必使用另一个lambda调用lambda,只需要在lambda函数权限设置中为步骤函数执行角色授予权限

以下设置是从AWS_Developer复制的:

"Version": "2012-10-17",
  "Id": "default",
  "Statement": [
    {
      "Sid": "sid-1",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::ACCOUNT_STEP_FUNCTION:root"
      },
      "Action": "lambda:InvokeFunction",
      "Resource": "FUNCTION_ARN"
    }
  ]
}