AWS Lambda and API Gateway integration provides a powerful combination for building serverless applications. By using AWS Lambda to execute code and API Gateway to manage API requests, you can easily create REST APIs, handle authentication, rate limiting, and integrate WebSocket APIs. These AWS Lambda MCQ questions and answers will help you deepen your knowledge of API Gateway integration and related topics, including authentication, authorization, and throttling.
Chapter 7: AWS Lambda and API Gateway Integration
1. What does API Gateway allow you to create with AWS Lambda?
a) SOAP APIs
b) RESTful APIs
c) Batch jobs
d) Lambda functions
2. Which of the following can be used for user authentication in API Gateway?
a) AWS IAM
b) Amazon Cognito
c) Lambda Authorizers
d) All of the above
3. What is the primary use of Amazon Cognito in API Gateway?
a) To create API routes
b) To manage user authentication and authorization
c) To manage Lambda execution permissions
d) To monitor API Gateway usage
4. How does API Gateway handle multiple HTTP methods for the same API endpoint?
a) By using Lambda functions only
b) Through routing configurations and method types
c) By managing query parameters
d) Using AWS CloudFront
5. What is the role of a Lambda Authorizer in API Gateway?
a) To invoke Lambda functions
b) To handle API rate limiting
c) To authorize API requests before they reach Lambda functions
d) To log API requests
6. How can you throttle requests in API Gateway?
a) By using IAM roles
b) By setting rate limits and burst limits
c) By creating multiple Lambda functions
d) By configuring CloudWatch
7. Which of the following can be used to limit the number of requests to an API in API Gateway?
a) Rate limiting
b) Throttling
c) Caching
d) All of the above
8. What does API Gateway use to prevent excessive traffic from overwhelming a service?
a) API Keys
b) Throttling and rate limiting
c) Lambda function scaling
d) S3 Buckets
9. Which of the following is NOT an API Gateway feature for managing API traffic?
a) Request validation
b) Traffic routing
c) Request transformation
d) Lambda scaling
10. How can caching be used in API Gateway?
a) To store API logs
b) To cache responses to reduce latency and load on backend services
c) To store Lambda function code
d) To create new API routes
11. Which AWS service can be integrated with API Gateway for WebSocket communication?
a) AWS Lambda
b) Amazon EC2
c) Amazon RDS
d) AWS S3
12. In API Gateway, what does the term “throttling” refer to?
a) Reducing API Gateway costs
b) Limiting the number of requests over a period of time
c) Creating new API routes
d) Validating API responses
13. What is the maximum rate limit for API Gateway requests per second?
a) 1000 requests per second
b) 5000 requests per second
c) 10,000 requests per second
d) 30,000 requests per second
14. Which of the following AWS services is primarily responsible for managing API Gateway usage and rate limits?
a) AWS IAM
b) AWS WAF
c) AWS CloudWatch
d) AWS API Keys
15. How can API Gateway ensure that only authorized users can access APIs?
a) By using API Keys
b) Through AWS IAM roles
c) By using Amazon Cognito or Lambda Authorizers
d) All of the above
16. What is a WebSocket API in API Gateway used for?
a) Handling real-time communication between clients and servers
b) Handling large data transfers
c) Creating scheduled tasks
d) Managing Lambda function logs
17. How does API Gateway handle method execution?
a) By invoking Lambda functions directly
b) By transforming requests and responses
c) By routing requests to specific services
d) By managing API Gateway logs
18. What feature does API Gateway provide to enhance security for REST APIs?
a) Caching
b) Throttling
c) API Keys and authorization
d) Request transformation
19. Which service can be used to track and analyze the performance of APIs in API Gateway?
a) AWS CloudTrail
b) AWS CloudWatch
c) AWS Lambda
d) AWS API Gateway Analytics
20. What can Lambda functions in API Gateway do in the context of WebSocket APIs?
a) Process HTTP requests
b) Handle WebSocket connections and messages
c) Route WebSocket traffic
d) Monitor WebSocket activity
21. What happens if an API Gateway method exceeds its rate limit?
a) The method is automatically deleted
b) Requests are rejected until the limit resets
c) The method is throttled to a lower rate
d) The API Gateway instance is paused
22. Which of the following is used to configure user access and permissions for API Gateway in AWS?
a) AWS IAM policies
b) Lambda function permissions
c) API Gateway API keys
d) All of the above
23. How can API Gateway integrate with AWS Lambda for handling various HTTP methods?
a) By using a single Lambda function for each HTTP method
b) By creating different Lambda functions for each HTTP method
c) By setting up HTTP methods in API Gateway and associating them with the same Lambda function
d) By using WebSocket APIs for different methods
24. What is the function of API Gateway’s request validation feature?
a) To validate the structure of incoming requests
b) To validate Lambda function responses
c) To validate API throttling limits
d) To validate the user’s credentials
25. How does API Gateway reduce the backend load for frequently requested resources?
a) By using caching
b) By using throttling
c) By using request transformation
d) By using multiple Lambda functions
26. What is a primary benefit of using Lambda Authorizers with API Gateway?
a) They handle API rate limiting
b) They provide fine-grained access control based on the request data
c) They manage API Gateway costs
d) They trigger Lambda functions asynchronously
27. Which method does API Gateway use to handle HTTP request transformations?
a) Through Lambda functions
b) Through API Gateway integration settings
c) Through API Keys
d) Through WebSocket APIs
28. How do you enable WebSocket communication in API Gateway?
a) By creating an API Gateway WebSocket API
b) By using Lambda functions only
c) By setting up multiple REST APIs
d) By configuring API Gateway with DynamoDB
29. What is the primary purpose of API Gateway’s rate limiting feature?
a) To prevent unauthorized access
b) To manage costs
c) To control the number of requests allowed over a specified time period
d) To validate incoming requests
30. What action should you take to configure authorization for an API Gateway endpoint?
a) Use AWS Cognito or Lambda Authorizer
b) Use API Keys only
c) Use CloudWatch metrics
d) Use EC2 instance roles
Qno | Answer |
---|---|
1 | b) RESTful APIs |
2 | d) All of the above |
3 | b) To manage user authentication and authorization |
4 | b) Through routing configurations and method types |
5 | c) To authorize API requests before they reach Lambda functions |
6 | b) By setting rate limits and burst limits |
7 | d) All of the above |
8 | b) Throttling and rate limiting |
9 | d) Lambda scaling |
10 | b) To cache responses to reduce latency and load on backend services |
11 | a) AWS Lambda |
12 | b) Limiting the number of requests over a period of time |
13 | c) 10,000 requests per second |
14 | c) AWS CloudWatch |
15 | d) All of the above |
16 | a) Handling real-time communication between clients and servers |
17 | b) By transforming requests and responses |
18 | c) API Keys and authorization |
19 | b) AWS CloudWatch |
20 | b) Handle WebSocket connections and messages |
21 | b) Requests are rejected until the limit resets |
22 | d) All of the above |
23 | c) By setting up HTTP methods in API Gateway and associating them with the same Lambda function |
24 | a) To validate the structure of incoming requests |
25 | a) By using caching |
26 | b) They provide fine-grained access control based on the request data |
27 | b) Through API Gateway integration settings |
28 | a) By creating an API Gateway WebSocket API |
29 | c) To control the number of requests allowed over a specified time period |
30 | a) Use AWS Cognito or Lambda Authorizer |