简体   繁体   中英

AWS Lambda to AWS Lambda permissions

Trying to use lambda.invoke method from the AWS docs. However I get permission issues when trying to test this.

Could anyway guide me on how to set up these permissions?

var aws = require('aws-sdk');
var lambda = new aws.Lambda({
  region: 'us-west-2' //change to your region
});

lambda.invoke({
  FunctionName: 'lambda_function',
  Payload: JSON.stringify('hello world') // pass params
}, function(error, data) {
  if (error) {
    context.done('error', error);
  }
  if(data.Payload){
   context.succeed(data.Payload)
  }
});

Using these docs http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html

You'll need to provide permissions to your caller Lambda function to invoke another function,
Your caller function will need an IAM Policy like -

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Lambda permission",
      "Action": [
        "lambda:InvokeFunction"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:lambda:awsRegion:awsAccountId:function:functionName"
    }
  ]
}

If you're calling your function from local,
Your AWS Credentials will need the same access

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM