A development team is building a mobile application for a bicycle-sharing service. The app allows users to log in using their social media accounts. The backend services expose a REST API hosted on Amazon API Gateway, backed by AWS Lambda. Additionally, the mobile app needs to upload user-generated profile photos directly to a private Amazon S3 bucket without routing the files through the application's backend.
Which two architectural steps should the developer take to implement authentication, API authorization, and secure S3 uploads with the least amount of custom code?
- Establish a user directory using Cognito User Pools, and deploy a built-in Cognito Authorizer on the API Gateway to secure the endpoints.Answer
- BDevelop a custom Lambda authorizer that manually validates the identity tokens against the social provider, and secure the API Gateway using resource policies.
- Link a Cognito Identity Pool to the user directory to obtain temporary AWS credentials, enabling the mobile client to upload photos to the S3 bucket.Answer
- DUtilize the Cognito User Pool to directly exchange JSON Web Tokens (JWT) for temporary IAM credentials for S3 bucket access.
- EConfigure an API Gateway Lambda Proxy integration that intercepts incoming requests and generates IAM execution policies dynamically for S3 upload.
Answer
Establish a user directory using Cognito User Pools, and deploy a built-in Cognito Authorizer on the API Gateway to secure the endpoints. Link a Cognito Identity Pool to the user directory to obtain temporary AWS credentials, enabling the mobile client to upload photos to the S3 bucket.
The correct solution uses Cognito User Pools for user authentication and secures the API Gateway REST API with the built-in Cognito Authorizer to minimize custom code. It then utilizes a Cognito Identity Pool linked to the User Pool to vend temporary AWS credentials, allowing the mobile application to upload profile photos directly to the private S3 bucket without passing through backend servers.
Step-by-Step Solution
Key Concept
Combining Cognito User Pools for user authentication/API authorization with Cognito Identity Pools for AWS resource access (S3 direct upload).