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 |
4o mini
get 30 MCQs on the below: Topics wise divide. I need exact 30 MCQs with random answers option(a,b,c,d). Without Answer. The Answer must be at Last in tabular form with columns Qno,Answer (Option with the text) Start with a 50 words intro with SEO optimized style and plain simple english. use keywords such as AWS DynamoDB mcq questions and answers Chapter 2: Basics of DynamoDB Data Models: Partition Key, Sort Key Creating and Managing Tables Read and Write Operations (PutItem, GetItem, Query, Scan) Consistency Models: Strong, Eventual Consistency Capacity Modes: Provisioned vs On-Demand
ChatGPT
AWS DynamoDB is a fast, flexible NoSQL database service designed for all applications requiring low-latency data access. Mastering its core concepts, such as partition keys, sort keys, and capacity modes, is vital for developers and architects. These AWS DynamoDB MCQ questions and answers cover topics like creating tables, read/write operations, consistency models, and capacity modes to boost your knowledge.
Chapter 2: Basics of DynamoDB
1. What is the primary use of the partition key in DynamoDB?
a) To sort data within a partition
b) To uniquely identify an item in the table
c) To determine table schema
d) To enforce data consistency
2. In DynamoDB, which combination uniquely identifies an item in a table?
a) Partition key only
b) Partition key and sort key
c) Table name and partition key
d) Table name and item ID
3. What is the main purpose of the sort key in a DynamoDB table?
a) To distribute data across partitions
b) To enforce schema validation
c) To enable multiple items with the same partition key
d) To control read/write capacity
4. Which DynamoDB API operation is used to retrieve a single item by its primary key?
a) PutItem
b) GetItem
c) Query
d) Scan
5. What is the key difference between a Query and a Scan operation in DynamoDB?
a) Query retrieves all items, while Scan retrieves specific items
b) Query works with a primary key, while Scan examines every item in the table
c) Query is slower, while Scan is faster
d) Query is limited to indexes, while Scan works only on tables
6. What happens when you perform a PutItem operation on an existing item in DynamoDB?
a) The operation is rejected
b) The existing item is updated with new attributes
c) A duplicate item is added to the table
d) The sort key is automatically modified
7. Which of the following describes strongly consistent reads in DynamoDB?
a) The data may be outdated but is faster to retrieve
b) The data is always up-to-date but might incur higher latency
c) Reads are replicated asynchronously
d) Only primary keys can be used for strong consistency
8. When is eventual consistency a good choice in DynamoDB?
a) For applications requiring real-time updates
b) For use cases where slight delays in replication are acceptable
c) When operating in provisioned mode only
d) For enforcing schema validation
9. How does DynamoDB distribute data across partitions?
a) Based on the size of the table
b) Using the partition key value
c) By using sort key hashing
d) Through manual configuration by the user
10. Which DynamoDB capacity mode is best suited for unpredictable workloads?
a) Provisioned mode
b) On-demand mode
c) Eventual consistency mode
d) Capacity scaling mode
11. What is the maximum size of a single item in DynamoDB, including all attribute values?
a) 256 KB
b) 400 KB
c) 1 MB
d) 5 MB
12. In DynamoDB, what is a Global Secondary Index (GSI)?
a) An alternate key for querying data
b) A primary key with additional attributes
c) A method to reduce read latency
d) A mechanism for sorting partitions
13. What does the Scan operation do in DynamoDB?
a) Searches for items by partition key
b) Reads every item in a table or index
c) Writes items into a table
d) Deletes items based on attributes
14. What is the maximum write capacity unit (WCU) that can be set for a DynamoDB table?
a) 1,000 WCU
b) 10,000 WCU
c) Unlimited WCU
d) Dynamically adjustable WCU
15. In provisioned mode, what happens if the provisioned capacity is exceeded during a read or write operation?
a) The operation is queued
b) The operation is throttled and rejected
c) The capacity is automatically increased
d) The operation is executed with eventual consistency
16. Which API operation is used to retrieve multiple items from a DynamoDB table?
a) BatchGetItem
b) Query
c) Scan
d) BatchWriteItem
17. What is the default consistency model for read operations in DynamoDB?
a) Strong consistency
b) Eventual consistency
c) Immediate consistency
d) Transactional consistency
18. How is data replicated in DynamoDB for durability?
a) Data is replicated to a single availability zone (AZ)
b) Data is replicated synchronously across three AZs
c) Data is replicated asynchronously across multiple regions
d) Data replication is optional
19. What is the key feature of On-Demand mode in DynamoDB?
a) Provides automatic scaling based on workload
b) Requires manual scaling for capacity
c) Is only available for tables without indexes
d) Reduces cost for predictable workloads
20. Which of the following is true about read capacity units (RCUs) in DynamoDB?
a) 1 RCU can read 1 KB of data per second for strongly consistent reads
b) 1 RCU can read 1 KB of data per second for eventually consistent reads
c) 1 RCU can read 4 KB of data per second for strongly consistent reads
d) 1 RCU can read 4 KB of data per second for eventually consistent reads
21. What is the main purpose of a Local Secondary Index (LSI) in DynamoDB?
a) It allows querying using an alternate sort key for the same partition key
b) It provides faster data replication
c) It improves read and write capacity
d) It is mandatory for all tables
22. Which API operation can be used to write multiple items into a DynamoDB table?
a) BatchPutItem
b) BatchWriteItem
c) BulkPutItem
d) MultiWriteItem
23. What attribute is mandatory when creating a DynamoDB table?
a) Sort key
b) Partition key
c) Primary index
d) Attribute names
24. Which consistency model in DynamoDB offers lower latency?
a) Strong consistency
b) Eventual consistency
c) Synchronous consistency
d) Deferred consistency
25. What happens when a DeleteItem operation is performed on a non-existent item in DynamoDB?
a) The operation fails
b) A placeholder item is created
c) The operation succeeds without error
d) The operation throws an exception
26. What is the maximum number of attributes an item in DynamoDB can have?
a) 10 attributes
b) 100 attributes
c) Unlimited
d) 200 attributes
27. What is the main advantage of using Global Tables in DynamoDB?
a) Improved query performance
b) Multi-region replication for high availability
c) Reduced costs for write operations
d) Faster indexing
28. In which DynamoDB mode do you need to define read and write capacity explicitly?
a) Provisioned mode
b) On-demand mode
c) Autoscaling mode
d) Transactional mode
29. Which DynamoDB operation can filter results based on attribute values?
a) Query
b) GetItem
c) PutItem
d) Scan
30. What is the maximum size of a DynamoDB table?
a) 10 TB
b) 1 PB
c) Unlimited
d) 100 GB
Qno | Answer |
---|---|
1 | b) To uniquely identify an item in the table |
2 | b) Partition key and sort key |
3 | c) To enable multiple items with the same partition key |
4 | b) GetItem |
5 | b) Query works with a primary key, while Scan examines every item in the table |
6 | b) The existing item is updated with new attributes |
7 | b) The data is always up-to-date but might incur higher latency |
8 | b) For use cases where slight delays in replication are acceptable |
9 | b) Using the partition key value |
10 | b) On-demand mode |
11 | b) 400 KB |
12 | a) An alternate key for querying data |
13 | b) Reads every item in a table or index |
14 | c) Unlimited WCU |
15 | b) The operation is throttled and rejected |
16 | a) BatchGetItem |
17 | b) Eventual consistency |
18 | b) Data is replicated synchronously across three AZs |
19 | a) Provides automatic scaling based on workload |
20 | a) 1 RCU can read 1 KB of data per second for strongly consistent reads |
21 | a) It allows querying using an alternate sort key for the same partition key |
22 | b) BatchWriteItem |
23 | b) Partition key |
24 | b) Eventual consistency |
25 | c) The operation succeeds without error |
26 | d) 200 attributes |
27 | b) Multi-region replication for high availability |
28 | a) Provisioned mode |
29 | a) Query |
30 | c) Unlimited |