Follow the steps in IAM Roles in the IAM User Guide
to create an IAM role (execution role).
As you follow the steps to create a role, note the following:

In Select Role Type, choose
AWS Service Roles, and then choose
AWS Lambda.

In Attach Policy, choose the policy
named AWSLambdaBasicExecutionRole.

Write down the Amazon Resource Name (ARN) of the IAM role. You
need this value when you create your Lambda function in the
next step.

Step 2.3 Create the Lambda function and Test It

In this section, you create a Lambda function containing an environment variable that
specifies an Amazon S3 bucket named Test. When invoked,
the function simply returns the name of the Amazon S3 bucket. Then you update the
configuration by changing the Amazon S3 bucket name to Prod
and when invoked again, the function returns the updated name of the Amazon S3 bucket.

To create the Lambda function, open a command prompt and run the following Lambda
AWS CLI create-function command. You need to provide the .zip file path and the execution role ARN.
Note that the Runtime
parameter uses nodejs6.10 but you can also specify nodejs4.3.

Optionally, you can upload the .zip file to an
Amazon S3 bucket in the same AWS region, and then specify the bucket and
object name in the preceding command. You need to replace the
--zip-file parameter with the --code
parameter. For example:

Copy

--code S3Bucket=bucket-name,S3Key=zip-file-object-key

Next, run the following Lambda CLI invoke command to invoke
the function. Note that the command requests asynchronous execution. You can
optionally invoke it synchronously by specifying
RequestResponse as the invocation-type parameter
value.