I am new to AWS Lambda
.
As given in the documentation, I deployed the following sample on AWS Lambda
using Claudia:
'use strict';
console.log('Loading hello world function');
exports.handler = function (event, context, callback) {
var name = "World";
var responseCode = 200;
console.log("request: " + JSON.stringify(event));
if (event.queryStringParameters !== null && event.queryStringParameters !== undefined) {
if (event.queryStringParameters.name !== undefined && event.queryStringParameters.name !== null && event.queryStringParameters.name !== "") {
console.log("Received name: " + event.queryStringParameters.name);
name = event.queryStringParameters.name;
}
if (event.queryStringParameters.httpStatus !== undefined && event.queryStringParameters.httpStatus !== null && event.queryStringParameters.httpStatus !== "") {
console.log("Received http status: " + event.queryStringParameters.httpStatus);
responseCode = event.queryStringParameters.httpStatus;
}
}
var responseBody = {
message: "Hello " + name + "!",
input: event
};
var response = {
statusCode: responseCode,
headers: {
"x-custom-header": "my custom header value"
},
body: JSON.stringify(responseBody)
};
console.log("response: " + JSON.stringify(response))
callback(null, response);
};
The command I used to deploy using Claudia
is:
claudia create --region us-east-1 --deploy-proxy-api --handler main.handler
It created a URL that looks like:
https://40barfooxpyj.execute-api.us-east-1.amazonaws.com/latest
Why do I get the string latest
in the URL? How could I make the URL look like:
https://40barfooxpyj.execute-api.us-east-1.amazonaws.com/api/jobs