amazon web services - AccessDeniedException: User is not authorized to perform: lambda:InvokeFunction -


i'm trying invoke lambda function node.

var aws = require('aws-sdk'); var lambda = new aws.lambda({     accesskeyid: 'id',     secretaccesskey: 'key',     region: 'us-west-2' });  lambda.invoke({     functionname: 'test1',     payload: json.stringify({         key1: 'arjun',         key2: 'kom',         key3: 'ath'     }) }, function(err, data) {     if (err) console.log(err, err.stack);     else     console.log(data); }); 

the keys iam user. user has awslambdaexecute , awslambdabasicexecutionrole policies attached.

i permission error: accessdeniedexception: user: arn:aws:iam::1221321312:user/cli not authorized perform: lambda:invokefunction on resource: arn:aws:lambda:us-west-2:1221321312:function:test1

i read docs , several blogs, i'm unable authorise user invoke lambda function. how user invoke lambda?

thanks.

the awslambdaexecute , awslambdabasicexecutionrole not provide permissions being expressed in error. both of these managed policies designed attached lambda function itself, it runs these policies.

the error saying user under nodejs program running not have rights start lambda function.

you need give iam user lambda:invokefunction permission:

  1. find user in iam management console , click it.
  2. on "permissions" tab, expand "inline policies" section , click "click here" link add policy".
  3. select "custom policy".
  4. give policy name. can anything.
  5. put policy in policy document field.

sample policy:

{     "version": "2012-10-17",     "statement": [         {             "sid": "stmt1464440182000",             "effect": "allow",             "action": [                 "lambda:invokeasync",                 "lambda:invokefunction"             ],             "resource": [                 "*"             ]         }     ] } 

in policy, have included both methods invoke lambda methods.

update:

there iam managed policy named awslambdarole can assign iam user or iam role. should give permissions need.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -