Chapter 3: Developing a Serverless Function with Lambda
- What's the command-line command to create an IAM role for an AWS Lambda function?
Answer: Create an IAM role with the below command; it allows Lambda function to call AWS services under your account:
aws iam create-role ROLE_NAME --assume-role-policy-document file://assume-role-lambda.json
The assume-role-lambda.json
file contains the following:
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Principal":{ "AWS":"*" }, "Action":"sts:AssumeRole" } ] }
- What's the command-line command to create a new S3 bucket in the Virginia region (
us-east-1
) and upload a Lambda deployment package to it?
Answer: The following command can be used to create an S3 bucket:
aws s3 mb s3://BUCKET_NAME --region us-east-1
To upload the deployment package to the bucket, issue the following command:
aws s3 cp deployment.zip s3://BUCKET_NAME --region us-east-1
- What are the Lambda package size limits?
- 10 MB
- 50 MB
- 250 MB
Answer: AWS Lambda deployment package has a total maximum of 50MB zipped and 250MB uncompressed.
- AWS Lambda Console supports editing Go source code.
- True
- False
Answer: False; Go is a recently added language, and the developers behind it haven't added the capability for an inline editor yet. Hence, you must provide an executable binary in a ZIP file format or reference an S3 bucket and object key where you have uploaded the deployment package.
- What's the underlying AWS Lambda execution environment?
- Amazon Linux Image
- Microsoft Windows Server
Answer: AWS Lambda execution environment is based on Amazon Linux AMI.
- How are events represented in AWS Lambda?
Answer: Events in AWS Lambda are represented in a JSON format.