Step 1 – setting up the repository

In the following example, we will use Node.js to create a few files. To set up your repository, do the following:

  1. 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(),    });};
  1. 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: ...

Get Expert AWS Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.