AccessDeniedException: User is not authorized to perform: lambda:InvokeFunction
<p>I'm trying to invoke a lambda function from node.</p>
<pre class="lang-js prettyprint-override"><code>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);
});
</code></pre>
<p>The keys are for an IAM user. The user has <code>AWSLambdaExecute</code> and <code>AWSLambdaBasicExecutionRole</code> policies attached.</p>
<p>I get a permission error:
<code>AccessDeniedException: User: arn:aws:iam::1221321312:user/cli is not authorized to perform: lambda:InvokeFunction on resource: arn:aws:lambda:us-west-2:1221321312:function:test1</code></p>
<p>I read the docs and several blogs, but I'm unable to authorise this user to invoke the lambda function. How do get this user to invoke lambda?</p>