Skip to Content

DVA-C02: How to Access Amazon S3 Files from an Amazon EC2 Instance Securely

Learn how to resolve the issue of an application that is hosted on an Amazon EC2 instance not showing any objects in an Amazon S3 bucket. Discover the most secure way to grant the application access to the files in the S3 bucket.

Table of Contents

Question

An application that is hosted on an Amazon EC2 instance needs access to files that are stored in an Amazon S3 bucket. The application lists the objects that are stored in the S3 bucket and displays a table to the user. During testing, a developer discovers that the application does not show any objects in the list.

What is the MOST secure way to resolve this issue?

A. Update the IAM instance profile that is attached to the EC2 instance to include the S3: * permission for the S3 bucket.

B. Update the IAM instance profile that is attached to the EC2 instance to include the S3: ListBucket permission for the S3 bucket.

C. Update the developer’s user permissions to include the S3: ListBucket permission for the S3 bucket.

D. Update the S3 bucket policy by including the S3: ListBucket permission and by setting the Principal element to specify the account number of the EC2 instance.

Answer

B. Update the IAM instance profile that is attached to the EC2 instance to include the S3: ListBucket permission for the S3 bucket.

Explanation

The most secure way to resolve this issue is B. Update the IAM instance profile that is attached to the EC2 instance to include the S3: ListBucket permission for the S3 bucket.

This solution will allow the application to list the objects in the S3 bucket without storing any credentials on the EC2 instance. The IAM instance profile is a container for an IAM role that passes role information and temporary security tokens to the EC2 instance. The S3: ListBucket permission is the minimum permission required for the application to display the table to the user. This solution follows the principle of least privilege, which means granting only the necessary permissions for a task.

The other options are not secure or optimal for the following reasons:

A. Update the IAM instance profile that is attached to the EC2 instance to include the S3: * permission for the S3 bucket.

This solution will grant full access to all actions and resources related to S3, which is more than what the application needs. This solution violates the principle of least privilege, which means granting only the necessary permissions for a task. This solution also increases the risk of accidental or malicious data loss or corruption.

C. Update the developer’s user permissions to include the S3: ListBucket permission for the S3 bucket.

This solution will not work because it does not address the issue of granting permissions to the application running on the EC2 instance. The developer’s user permissions are not relevant for this scenario, as they are not used by the application. This solution also introduces a security risk, as it exposes the developer’s credentials to potential compromise.

D. Update the S3 bucket policy by including the S3: ListBucket permission and by setting the Principal element to specify the account number of the EC2 instance.

This solution will work, but it is not as secure or scalable as option B. The S3 bucket policy is a resource-based policy that controls access to the S3 bucket. The Principal element specifies who can access the bucket. By setting it to the account number of the EC2 instance, this solution grants access to all instances in that account, which may not be desirable. This solution also requires additional configuration and maintenance, as any changes to the bucket policy or the account number will affect access.

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