
Answer-first summary for fast verification
Answer: Use an IAM Instance Role
Use an IAM Instance Role An instance profile is a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts. The AWS SDK will use the EC2 metadata service to obtain temporary credentials thanks to the IAM instance role. This is the most secure and common setup when deploying any kind of applications onto an EC2 instance. Incorrect options: Use environment variables - This is another option if you configure AWS CLI on the EC2 instance. When configuring the AWS CLI you will set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. This practice may not be bad for one instance but once you start running more EC2 instances this is not a good practice because you may have to change credentials on each instance whereas an IAM Role gets temporary permissions. Hardcode the credentials in the application code - It will work for sure, but it's not a good practice from a security point of view. Use the SSM parameter store - With parameter store you can store data such as passwords. The problem is that you need the SDK to access parameter store and without credentials, you cannot use the SDK. Use parameter store for other uses such as database connection strings or other secret codes when you have already authenticated to AWS.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Your web application, hosted on EC2, performs GET and PUT requests for objects stored in Amazon Simple Storage Service (S3) using the SDK for PHP. During a security review, it was discovered that your application employs hardcoded IAM access keys and secret access keys to access AWS services. The security team has recommended a more secure configuration that utilizes temporary credentials.
Which of the following options can be used to address the given use-case?
A
Hardcode the credentials in the application code
B
Use environment variables
C
Use an IAM Instance Role
D
Use the SSM parameter store
No comments yet.