This template invokes an AWS Lambda function and retrieves a specific value from the JSON result.

Terraform Template

data "aws_lambda_invocation" "example" {
  function_name = "aws_lambda_function.lambda_function_test.function_name"
  input = <<-EOF
    {
     "key1": "value1",
     "key2": "value2"
    }
    
  EOF
}

output "result_entry" {
  value = jsondecode(data.aws_lambda_invocation.example.result)["key1"]
}