5

In aws step function i need to call api gateway endpoint with path parameters from previous state values. enter image description here

Step Function Code (Api Gateway Call)

"API Gateway Request": {
  "Type": "Task",
  "Resource": "arn:aws:states:::apigateway:invoke",
  "Parameters": {
    "ApiEndpoint": "****.amazonaws.com",
    "Method": "GET",
    "Headers": {
      "Accept": [
        "application/json"
      ]
    },
    "Stage": "dev",
    "Path": "/sample/$.id",
    "AuthType": "IAM_ROLE"
  },
  "InputPath": "$.id",
  "Next": "Lambda Invoke",
  "ResultPath": "$.myStateInput"
}

Input to this state:

{ "id": "1231" }

Instead of replacing "$.id" as "1231", it just calling url like below enter image description here Api Gateway:

enter image description here

Please tell what i'm doing wrong ?

5
  • 1
    Did you try with States.Format('/sample/{}', $.id)? Commented Sep 6, 2021 at 9:52
  • 1
    @Marcin yes working. Commented Sep 6, 2021 at 10:00
  • Glad it worked out. I added an answer if you don't mind. Commented Sep 6, 2021 at 10:02
  • Acceptance of the answer would be appreciated. Commented Sep 6, 2021 at 23:47
  • 1
    @Marcin please accept my edit to your answer "Path.$": States.Format('/sample/{}', $.id) Commented Sep 8, 2021 at 10:21

1 Answer 1

5

Based on the comments, the solution was to use intrinsic function:

"Path.$": States.Format('/sample/{}', $.id)

State Code

"API Gateway Request": {
  "Type": "Task",
  "Resource": "arn:aws:states:::apigateway:invoke",
  "Parameters": {
    "ApiEndpoint": "**.amazonaws.com",
    "Method": "GET",
    "Headers": {
      "Accept": [
        "application/json"
      ]
    },
    "Stage": "dev",
    "Path.$": "States.Format('/sample/{}', $.id)",
    "AuthType": "IAM_ROLE"
  },
  "Next": "Lambda Invoke",
  "ResultPath": "$.myStateInput"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.