A developer is designing a smart-home mobile application that allows authenticated users to read their device telemetry data directly from an Amazon DynamoDB table. The solution must minimize backend server management and allow the mobile app to make direct, secure SDK calls to DynamoDB using temporary AWS credentials, restricting users to only access their own data. Which architecture should the developer implement to meet these requirements?
- Configure an Amazon Cognito User Pool for user authentication and directory services, and an Amazon Cognito Identity Pool to exchange the User Pool tokens for temporary AWS credentials. Associate an IAM role with the Identity Pool that uses a policy with a dynamodb:LeadingKeys condition matching the Cognito identity ID.Answer
- BConfigure an Amazon Cognito User Pool for user authentication. Have the mobile application send the User Pool ID token directly in the authorization header of the AWS SDK client to perform DynamoDB operations.
- CConfigure an Amazon Cognito User Pool for user authentication. Set up Amazon API Gateway with a custom Lambda Authorizer that parses the JWT, validates it against the User Pool, and performs the DynamoDB operations directly within the authorizer function.
- DConfigure an Amazon Cognito Identity Pool as the user directory to manage user sign-ups and logins. Configure the mobile application to use the Identity Pool credentials to access DynamoDB, relying on application-side logic to filter data access.
Answer
Configure an Amazon Cognito User Pool for user authentication and directory services, and an Amazon Cognito Identity Pool to exchange the User Pool tokens for temporary AWS credentials. Associate an IAM role with the Identity Pool that uses a policy with a dynamodb:LeadingKeys condition matching the Cognito identity ID.
The correct architecture uses Cognito User Pools to authenticate the users, and Cognito Identity Pools to exchange those tokens for temporary AWS credentials. By applying a policy with a dynamodb:LeadingKeys condition matching the Cognito identity ID on the IAM role assumed via the Identity Pool, the developer achieves direct, fine-grained access control to the DynamoDB table with minimal operational overhead.
Step-by-Step Solution
Key Concept
Integration of Amazon Cognito User Pools and Identity Pools for direct, fine-grained access to AWS services.
Estimated Time:2m 0s