3

I tried to edit the lambda function using AWS Cloud 9 but unfortunately, the layers were not imported. How do I attach lambda layers to it?

var config = require('./config.js');
        
var AWS = require("aws-sdk");

//How to import Axios in cloud 9 as I have added Axios layer in Lambda
const axios = require("axios");

exports.handler = async(event, context, callback) => {

    //Get DataList
    var get_data = await config.connectToDatabase()
        .then(db => config.get_items(db))
        .then(result => {
            console.log(result);
            return result;
        });


    callback(null, get_data);
}

The code is working fine when I run this function in lambda but there is an error when I tried the same function in cloud 9, It says Module not found Axios because Cloud 9 does not support layers.

Jens
  • 20,533
  • 11
  • 60
  • 86
Taha Farooqui
  • 637
  • 10
  • 25

0 Answers0