A developer is building a serverless web application that allows authenticated users to read and write items in a shared Amazon DynamoDB table. The application needs to support self-service user registration and login, as well as authenticate users via a secure directory. The client application runs in the browser and must interact directly with the DynamoDB table using temporary AWS credentials, ensuring that each user can only access items where the partition key matches their unique user identifier. Which combination of steps should the developer perform to configure the authentication and authorization mechanism? (Select TWO.)
- Create an Amazon Cognito User Pool to serve as the user directory and handle user registration, authentication, and token generation.Cevap
- BCreate an Amazon Cognito Identity Pool to manage the user directory and handle user registration, and use a custom API Gateway Lambda authorizer to validate users.
- Create an Amazon Cognito Identity Pool, configure the User Pool as an identity provider, and associate the authenticated IAM role with a policy that restricts DynamoDB access using the `${cognito-identity.amazonaws.com:sub}` policy variable.Cevap
- DConfigure an API Gateway Cognito authorizer that validates the user's ID token and directly modifies the trust policy of the DynamoDB table's IAM role to allow direct client access.
- ECreate an Amazon Cognito User Pool and modify the associated IAM trust policy to allow the User Pool to directly execute the `sts:AssumeRole` API call to retrieve credentials for the client application.
Cevap
Create an Amazon Cognito User Pool to serve as the user directory and handle user registration, authentication, and token generation; and create an Amazon Cognito Identity Pool, configure the User Pool as an identity provider, and associate the authenticated IAM role with a policy that restricts DynamoDB access using the `${cognito-identity.amazonaws.com:sub}` policy variable.
The correct architecture requires Cognito User Pools to manage the user identity directory and authentication. It then requires Cognito Identity Pools to authenticate those users against AWS services by exchanging user pool tokens for temporary AWS credentials. Fine-grained access control in DynamoDB is enforced by applying an IAM policy to the authenticated role using the `${cognito-identity.amazonaws.com:sub}` policy variable as a condition matching the partition key.
Adım Adım Çözüm
Anahtar Kavram
The separation of concerns between Amazon Cognito User Pools (authentication/directory) and Identity Pools (authorization/temporary credentials), and using fine-grained access control policies.