A developer is designing a serverless architecture for a report distribution application. The frontend is a Single Page Application (SPA) hosted on Amazon S3. The backend APIs are deployed using Amazon API Gateway. The developer needs to implement sign-up and sign-in functionality for users, secure the API Gateway endpoints, and allow the SPA to download reports directly from a private S3 bucket after authentication.
Which combination of actions should the developer take to meet these requirements securely? (Select TWO.)
- Create an Amazon Cognito User Pool to manage user registration and authentication, and configure a Cognito User Pool Authorizer on the API Gateway REST API.Answer
- Create an Amazon Cognito Identity Pool, link it to the User Pool, and map users to an authenticated IAM role that allows reading from the private S3 bucket.Answer
- CCreate an Amazon Cognito Identity Pool to manage user registration and directory services, and configure a built-in Cognito Authorizer on the API Gateway REST API.
- DConfigure a custom Lambda Authorizer in API Gateway to generate and return temporary AWS credentials from the Cognito Identity Pool directly in the authorization response.
- ECreate an IAM role with permissions to read from the private S3 bucket, and configure its trust policy to allow the API Gateway service principal to assume the role.
Answer
Create an Amazon Cognito User Pool to manage user registration and authentication, and configure a Cognito User Pool Authorizer on the API Gateway REST API. Also, create an Amazon Cognito Identity Pool, link it to the User Pool, and map users to an authenticated IAM role that allows reading from the private S3 bucket.
To implement these requirements securely, the developer must use a Cognito User Pool to handle user authentication and registration. API Gateway integrates natively with Cognito User Pools using a built-in authorizer to validate the JWT tokens generated during login. For direct S3 access from the browser, Cognito Identity Pools (federated identities) should be used. The Identity Pool integrates with the User Pool as an identity provider and exchanges the User Pool tokens for temporary AWS credentials, which are mapped to an authenticated IAM role that grants permissions to the private S3 bucket.
Step-by-Step Solution
Key Concept
Using Cognito User Pools for authentication and API Gateway protection, combined with Cognito Identity Pools for temporary AWS credentials to access S3.