Call aws-cli from AWS Lambda

前端 未结 5 1987
我寻月下人不归
我寻月下人不归 2020-12-02 20:03

is there ANY way to execute aws-cli inside AWS Lambda? It doesn\'t seem to be pre-installed. (I\'ve checked with \"which aws\" via Node.js child-process, and it didn\'t exis

5条回答
  •  醉酒成梦
    2020-12-02 20:33

    You can use the AWS node.js SDK which should be available in Lambda without installing it.

    var AWS = require('aws-sdk');
    var lambda = new AWS.Lambda();
    lambda.invoke({
        FunctionName: 'arn:aws:lambda:us-west-2:xxxx:function:FN_NAME',
        Payload: {}, 
      },
      function(err, result) {
        ...
    });
    

    As far as I can tell you get most, if not all the cli functionality. See the full documentation here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html

提交回复
热议问题