내용으로 건너뛰기

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!

질문됨 일 년 전219회 조회

1개 답변
-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

답변함 일 년 전

  • 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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.