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:
- find user in iam management console , click it.
- on "permissions" tab, expand "inline policies" section , click "click here" link add policy".
- select "custom policy".
- give policy name. can anything.
- 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
Post a Comment