Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to build query parameters for api gateway from input path step function?

I am trying to build step function that invokes my api gateway proxy. I am unable to pass input to query parameters. What is the correct syntax and can it be done?

I’ve tried "$.zzId" but it does not replace it with the input value.

        "Branches": [
        {
          "StartAt": "Get Content",
          "States": {
            "Get Content": {
              "Type": "Task",
              "Resource": "arn:aws:states:::apigateway:invoke",
              "Parameters": {
                "ApiEndpoint": "zcxzscaw.execute-api.us-east-1.amazonaws.com",
                "Method": "GET",
                "Headers": {},
                "Path": "/bmx/content",
                "zzId" : "$.zzId" // <-- this resolves it with correct value but fails to execute step function because it is invalid attribute, but at least I know that it is correct path
                "QueryParameters": {
                  "zzId": [
                    "$.zzId" // <-- this does not do anything 
                  ]
                },
                "RequestBody": {},
                "AuthType": "NO_AUTH"
              },
              "TimeoutSeconds": 3,
              "End": true
            }
          }
        }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Put a .$ suffix on keys you want to Step Functions to substitute the values. Substitutions expect a string value, so use the States.Array intrinsic function to wrap the value in an array.

GIVEN:

"QueryParameters": {
    "zzId.$": "States.Array($.zzId)"
},

WHEN the input is {"zzId": "Hello world"}

THEN the output is:

"QueryParameters": {
    "zzId": ["Hello world"]
},
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading