0
0
AWScloud~20 mins

REST API creation in AWS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
REST API Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
REST API Endpoint Response Behavior
You have created a REST API in AWS API Gateway with a GET method integrated with a Lambda function. The Lambda function returns a JSON object with a statusCode and body. What will the API Gateway return to the client if the Lambda returns {"statusCode": 200, "body": "{\"message\": \"Hello\"}"}?
AThe client receives a 502 Bad Gateway error because the Lambda response is invalid.
BThe client receives a JSON response with status 200 and body {"message": "Hello"}.
CThe client receives a plain text response with the string {"message": "Hello"} and status 200.
DThe client receives a JSON response with status 200 and body as a string containing escaped JSON.
Attempts:
2 left
💡 Hint
Remember that API Gateway expects the Lambda to return a string in the body field, which is sent as-is to the client.
Configuration
intermediate
2:00remaining
Configuring CORS for REST API
You want to enable CORS on an AWS API Gateway REST API resource to allow requests from any origin. Which configuration will correctly enable CORS?
AAdd an OPTIONS method with a MOCK integration that returns headers including Access-Control-Allow-Origin: '*'.
BAdd a GET method and set Access-Control-Allow-Origin: '*' in the Lambda function response headers.
CEnable CORS in the API Gateway console by checking the box 'Enable CORS' on the resource and redeploy the API.
DAdd a POST method with a Lambda integration and set Access-Control-Allow-Origin: '*' in the method response.
Attempts:
2 left
💡 Hint
CORS requires a preflight OPTIONS request that returns specific headers.
Architecture
advanced
2:00remaining
Designing a Secure REST API with AWS Services
You need to design a REST API that only allows authenticated users to access certain endpoints. Which AWS service combination provides the best security and scalability?
AUse API Gateway with resource policies to restrict IP addresses and integrate directly with EC2 instances.
BUse API Gateway with IAM roles assigned to users and integrate with Lambda functions without authentication.
CUse API Gateway with Lambda authorizer to validate JWT tokens issued by Amazon Cognito, and integrate with Lambda functions.
DUse API Gateway with no authentication and rely on Lambda functions to check user credentials.
Attempts:
2 left
💡 Hint
Think about managed authentication services and token validation.
Best Practice
advanced
2:00remaining
Optimizing REST API Performance in AWS
Which practice will most effectively reduce latency and improve performance for a global REST API deployed with AWS API Gateway and Lambda?
ADeploy API Gateway with edge-optimized endpoint and use a single Lambda function in one region.
BEnable API Gateway caching on frequently requested endpoints and deploy Lambda functions in multiple regions with latency-based routing.
CUse API Gateway without caching and rely on Lambda cold start optimization techniques only.
DIncrease Lambda memory size to maximum and use a single region deployment for simplicity.
Attempts:
2 left
💡 Hint
Consider caching and geographic distribution to reduce latency.
security
expert
3:00remaining
Preventing Unauthorized Access in REST API
You have a REST API in API Gateway integrated with Lambda. You want to ensure that only requests with a valid API key and a specific custom header 'X-Client-Id' are allowed. Which configuration enforces this requirement most securely?
AEnable API key requirement on the API Gateway method and use a Lambda authorizer to validate the 'X-Client-Id' header.
BRequire API key on the method and check 'X-Client-Id' header inside the Lambda function code.
CUse resource policies to allow only requests with the API key and 'X-Client-Id' header.
DUse IAM authorization with API Gateway and pass 'X-Client-Id' as a query parameter.
Attempts:
2 left
💡 Hint
Think about combining API Gateway features for authentication and custom header validation.