Bug - AWS Step Functions

0

Hi everyone,

I’m running into what seems like a bug when trying to use a JsonPath reference in the ApiEndpoint field of an Api Gateway Invoke state in AWS Step Functions.

According to the official documentation, it should be possible to use the .$ syntax to reference input values. For example, given this input:

{ "customer_id": "1234567890", "name": "John Doe" } You should be able to define the ApiEndpoint like this: "ApiEndpoint.$": "States.Format('https://api.stripe.com/v1/customers/{}', $.customer_id)"

However, when I try this (or any similar reference using .$), I receive an error as if the Step Function is not accepting the $ path. It seems like the value inside States.Format is not resolving the JsonPath as expected.

I've double-checked the syntax and tried other variations, but the issue persists. It feels like the $ path isn't being parsed or allowed in this context.

Has anyone else encountered this? Could this be a recent bug or an undocumented limitation?

Appreciate any help or insights!

asked a month ago98 views
1 Answer
-1

To address the issue you're encountering with using JsonPath references in the ApiEndpoint field of an AWS Step Functions state, Ensure your state definition is correctly formatted. Here’s an example that should work:

{
  "StartAt": "InvokeAPI",
  "States": {
    "InvokeAPI": {
      "Type": "Task",
      "Resource": "arn:aws:states:::apigateway:invoke",
      "Parameters": {
        "ApiEndpoint.$": "States.Format('https://api.stripe.com/v1/customers/{}', $.customer_id)",
        "Method": "GET",
        "Headers": {
          "Authorization.$": "States.Format('Bearer {}', $.auth_token)"
        }
      },
      "End": true
    }
  }
}
AWS
answered a month ago
  • Thank you for your response and the example Step Function definition. I followed your example, but I'm still encountering the same error. To simplify and isolate the issue, I removed the 'Headers' attribute from my 'InvokeAPI' state and kept only the 'ApiEndpoint' with the JsonPath reference.

    Here's the simplified definition of my state:

    {
      "StartAt": "Pass",
      "States": {
        "Pass": {
          "Type": "Pass",
          "Next": "InvokeAPI",
          "Result": {
            "customer_id": 123
          }
        },
        "InvokeAPI": {
          "Type": "Task",
          "Resource": "arn:aws:states:::apigateway:invoke",
          "Parameters": {
            "ApiEndpoint.$": "States.Format('https://api.stripe.com/v1/customers/{}', $.customer_id)",
            "Method": "GET"
          },
          "End": true
        }
      }
    }
    

    The error I continue to receive is:

    An error occurred while executing the state 'InvokeAPI' (entered at the event id #4). The Parameters '{"Method":"GET","ApiEndpoint":"https://api.stripe.com/v1/customers/123"}' could not be used to start the Task: [The value for the 'ApiEndpoint' field is not valid]
    

    As you can see, even with the simplified configuration, the error persists, indicating that the problem seems to be specifically related to the use of JsonPath in the 'ApiEndpoint' attribute. The value of 'customer_id' is being correctly substituted within States.Format, but ApiGateway does not accept the final value.

    Any ideas why this might be happening or if there are any additional config

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions