In the following example, we will use Node.js to create a few files. To set up your repository, do the following:
- Create the index.js file with the following code:
var time = require('time');exports.handler = (event, context, callback) => { var currentTime = new time.Date(); currentTime.setTimezone("America/New_York"); callback(null, { statusCode: '200', body: 'Time in New York : ' + currentTime.toString(), });};
- Create the packt.yaml file with the following code. This is a SAM template file to define the resources. It will define a Lambda function which will be triggered by the API gateway:
AWSTemplateFormatVersion: '2010-09-09'Transform: AWS::Serverless-2016-10-31Description: Outputs the timeResources: ...