AWS state machine workflow which includes multiple lambda but it seems First lambda is failing to pass output to next lambda.
All Lambda will have output in the below format, except body will be different for each lambda.
{
"statusCode": 200,
"body": {
"key": "aws/myfile.json",
"bucket_id": "bucket-name"
}
}
State machine Code: My requirement is simply passing the output of the previous step as input to the next step. I think I am missing $inputpath
and $outputpath
configuration in state_function json file. Can someone help on checking below terraform code.
{
"Comment": "Get AWS Permission data step function",
"StartAt": "Get Account Permission Sets",
"States": {
"Get Account Permission Sets": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "${aws_accounts_function_arn}:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "Get Account Assignment",
"InputPath": "$.Payload"
},
"Get Account Assignment": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"FunctionName": "${aws_accounts_function_arn}:$LATEST",
"Payload.$": "$"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "Get Groups Assignment",
"InputPath": "$.Payload"
},
"Get Groups Assignment": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "${aws_accounts_function_arn}:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "Put Item Into DynamoDB",
"InputPath": "$.Payload"
},
"Put Item Into DynamoDB": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"OutputPath": "$.Payload",
"Parameters": {
"Payload.$": "$",
"FunctionName": "${aws_accounts_function_arn}:$LATEST"
},
"Retry": [
{
"ErrorEquals": [
"Lambda.ServiceException",
"Lambda.AWSLambdaException",
"Lambda.SdkClientException",
"Lambda.TooManyRequestsException"
],
"IntervalSeconds": 2,
"MaxAttempts": 6,
"BackoffRate": 2
}
],
"Next": "State Result"
},
"State Result": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.statusCode",
"NumericEquals": 200,
"Next": "Success"
}
],
"Default": "Fail",
"InputPath": "$.statusCode"
},
"Success": {
"Type": "Succeed"
},
"Fail": {
"Type": "Fail"
}
}
}
When I execute, the state machine throws an error below
An error occurred while executing the state 'Get Account Assignment' (entered at the event id #7). Invalid path '$.Payload' : No results for path: $['Payload']