curllambdayamltaskfile

How can I fix this Taskfile command?


I'm trying to test a local Lambda function using the public.ecr.aws/lambda/python:3.8 image. I having a problem with the proper escape/encoding for a curl POST to this API endpoint using task.

The API complains if the json payload is encoded:

[test] {"errorMessage": "Unable to unmarshal input: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)", "errorType": "Runtime.UnmarshalError", "stackTrace": []}

The task command complains if it is not:

yaml: line 7: did not find expected key

Here is taskfile.yml:

version: "3"

tasks:
    default:
        desc: Test the API
        cmds:
        - curl -XPOST http://localhost:9000/2015-03-31/functions/function/invocations -d '{'name': 'Todd'}'

Solution

  • Taskfile vomits on ":" in certain places (e.g. desc or cmds element). You can try the following, using the pipe:

    version: "3"
    
    tasks:
        default:
            desc: Test the API
            cmds:
            - |
              curl -XPOST http://localhost:9000/2015-03-31/functions/function/invocations -d '{'name': 'Todd'}'