Skip to Content

DVA-C02: How to Integrate Amazon Cognito and Amazon S3 for Secure File Upload and Download

Learn how to use Amazon Cognito user pools and identity pools to authenticate and authorize users for your application. Find out how to use Amazon S3 to store and retrieve user-specific files securely and efficiently.

Table of Contents

Question

An application is using Amazon Cognito user pools and identity pools for secure access. A developer wants to integrate the user-specific file upload and download features in the application with Amazon S3.

The developer must ensure that the files are saved and retrieved in a secure manner and that users can access only their own files. The file sizes range from 3 KB to 300 MB.

Which option will meet these requirements with the HIGHEST level of security?

A. Use S3 Event Notifications to validate the file upload and download requests and update the user interface (UI).

B. Save the details of the uploaded files in a separate Amazon DynamoDB table. Filter the list of files in the user interface (UI) by comparing the current user ID with the user ID associated with the file in the table.

C. Use Amazon API Gateway and an AWS Lambda function to upload and download files. Validate each request in the Lambda function before performing the requested operation.

D. Use an IAM policy within the Amazon Cognito identity prefix to restrict users to use their own folders in Amazon S3.

Answer

D. Use an IAM policy within the Amazon Cognito identity prefix to restrict users to use their own folders in Amazon S3.

Explanation

The correct answer is D. Use an IAM policy within the Amazon Cognito identity prefix to restrict users to use their own folders in Amazon S3.

Here is a detailed explanation:

  • Option A is not a valid solution because it does not provide a secure way to upload and download files. S3 Event Notifications are messages that Amazon S3 sends to notify about changes to objects in a bucket. They are not meant to validate or authorize requests to access objects. Moreover, using S3 Event Notifications to update the user interface (UI) may introduce latency and inconsistency, as they are delivered asynchronously and may not reflect the current state of the objects.
  • Option B is not a valid solution because it does not enforce access control at the Amazon S3 level. Saving the details of the uploaded files in a separate Amazon DynamoDB table may help to filter the list of files in the user interface (UI), but it does not prevent users from accessing other users’ files if they know the object keys or URLs. Moreover, using a separate table may introduce complexity and overhead, such as managing the database schema and capacity, and ensuring data consistency and durability.
  • Option C is not a valid solution because it requires an additional service, which is not necessary and may incur additional costs. Using Amazon API Gateway and an AWS Lambda function to upload and download files may provide a way to validate each request in the Lambda function, but it also adds complexity and overhead, such as managing the API endpoints and resources, configuring the Lambda function code and settings, and handling errors and retries. Moreover, using this solution may introduce latency and performance issues, as the Lambda function needs to act as a proxy between the users and Amazon S3.
  • Option D is the best solution because it provides the highest level of security for user-specific file upload and download features. By using an IAM policy within the Amazon Cognito identity prefix, users can be restricted to use their own folders in Amazon S3 based on their unique identities. This way, users can only access their own files and cannot access other users’ files. Moreover, this solution does not require any additional services or components, as it leverages the native features of Amazon Cognito and Amazon S3.

Therefore, option D is the best solution that meets these requirements with the highest level of security.

The latest AWS Certified Developer – Associate DVA-C02 certification actual real practice exam question and answer (Q&A) dumps are available free, which are helpful for you to pass the AWS Certified Developer – Associate DVA-C02 exam and earn AWS Certified Developer – Associate DVA-C02 certification.

AWS Certified Developer - Associate DVA-C02 Exam Questions and Answers