A retail company has a web application hosted on an Amazon EC2 instance that needs to read and write images to an Amazon S3 bucket. According to AWS security best practices, which of the following is the most secure method to grant the EC2 instance access to the S3 bucket?
- Attach an IAM role with the required S3 permissions to the EC2 instance.Answer
- BEmbed the AWS Account Root User access keys directly within the application code.
- CCreate an IAM user, generate long-lived access keys, and store them on the EC2 instance.
- DContact AWS Support to configure the network permissions between the EC2 instance and the S3 bucket.
Answer
Attach an IAM role with the required S3 permissions to the EC2 instance.
Attaching an IAM role to the EC2 instance is the recommended best practice. AWS automatically provides temporary, short-lived security credentials to the EC2 instance through the Instance Metadata Service (IMDS). This eliminates the need to hardcode or store permanent AWS access keys on the instance, reducing the risk of credential exposure.
Step-by-Step Solution
Key Concept
Using IAM Roles for AWS Services
Estimated Time:45s