Here’s my yml file ->
service: presto-contact-service
plugins:
- serverless-plugin-include-dependencies
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: us-west-2
iamRoleStatements:
- Effect: “Allow”
Action:
- “ses:SendEmail”
Resource: “*”
functions:
newcontact:
handler: handler.newcontact
events:
- http:
path: /
method: get
cors: true
and my simple function.
‘use strict’;
const querystring = require(‘querystring’);
const AWS = require(‘aws-sdk’);
const emailer = require(‘ses-email-sender’);
module.exports.newcontact = (event, context, callback) => {
// get the data on the form in an array.
var formAttributes = querystring.parse(event.body);
console.log(formAttributes);
const response = {
statusCode: 200,
headers: {
“Access-Control-Allow-Origin” : “*”,
“Access-Control-Allow-Credentials” : true, // probably 100% unnecessary…
“Content-Type” : “application/json” // doesn’t matter if this is here or not on the response.
},
body: JSON.stringify({ message: ‘great!’, input: event }),
};
callback(null, response);
};
In looking at the log files generated by the lambda function, the function is working great. however, the gateway api is still barfing and spitting back a 502 error. honestly…i’ve seen a bit of comments around this and they generally fall into the category of “you aren’t using the right response object in the callback…”. but i am pretty sure I am here…