Problem executing commands in windows

6 posts / 0 new
Last post
Problem executing commands in windows

While running the below command of the recipe 'Building your first API with Lambda integration' of Chapter 2, I am getting an exception.

aws apigateway put-integration \
    --rest-api-id 19sh9qhri2 \
    --resource-id n9iev1 \
    --http-method GET \
    --type AWS \
    --integration-http-method POST \
    --uri 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:<account_id>:function:lambda-for-api-gateway/invocations' \
    --request-templates '{"application/json": "{\"name\": \"$input.params('"'"'name'"'"')\" , \"time\": \"$input.params('"'"'time'"'"')\"}"}' \
    --region us-east-1 \
    --profile admin

 

Exception is 

Unknown options: ,, "time":, "$input.params('''time''')"}}' ^, "$input.params('''name''')"

Add Proper escape characters

Please add correct escape characters specific to windows so that the final velocity mapping template for api gateway is below

 {"name":"$input.params('name')","time":"$input.params('time')"}

Getting another error after addingescape characters

I tried below value for request template

 --request-templates {\"application/json\":{\"name\":\"$input.params(name)\",\"time\":\"$input.params(time)\"}}

But got the exception 

Invalid type for parameter requestTemplates.application/json, value: OrderedDict([('name', '$input.params(name)'), ('time', '$input.params(time)')]), type: <class 'collections.OrderedDict'>, valid types: <class 'str'>

Tried mulitple options. Either getting above error or the first Unknown exception error.

Windows specific command

Please use the below line for request template

--request-templates {\"application/json\":\"{\\\"name\\\":\\\"$input.params('name')\\\",\\\"time\\\":\\\"$input.params('time')\\\"}\"} 

Multiple escape characters are required because params should be in single quote for velocity template and while running the commands you will see below console output

{
    "type": "AWS",
    "httpMethod": "POST",
    "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:<account-id>:function:<lamda-function-name>/invocations",
    "requestTemplates": {
        "application/json": "{\"name\":\"$input.params('name')\",\"time\":\"$input.params('time')\"}"
    },
    "passthroughBehavior": "WHEN_NO_MATCH",
    "timeoutInMillis": 29000,
    "cacheNamespace": "eux3cn",
    "cacheKeyParameters": []
}

This will create correct velocity template for api-gateway

 

It worked, Thanks a ton!

It worked, Thanks a ton!

Interested in

1.AWS

2.Cloud

3.Database

4.Certification

5.DevOps

Contact

We learn together, do innovations and then document them.

Offline Contact
We connect physically only in Bengaluru currently, but most of our activities happen online. Please follow us here or in social media for more details.
WhatsApp (Primary): (+91) 7411174113
WhatsApp (Secondary): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About Cloudericks

Team Cloudericks is a community to learn about and master cloud computing. Current learning focus is on AWS cloud.

We believe that knowledge is useless unless you share it; the more you share, the more you learn. Visit Cloudericks.

Recent comments

Photo Stream