Here is a jsFiddle (http://jsfiddle.net/oxybbatu/10/) of the working code. Make sure to replace its Lambda name with your Lambda name and its poolId with your poolId or else it will not work as expected.