You are deploying an application on Amazon EC2 that must call AWS APIs.
Which method would you use to allow the application access to the APIs securely?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer - D.
AWS Documentation mentions the following:
You can use roles to delegate access to users, applications, or services that don't normally have access to your AWS resources.
It is not a good practice to use IAM credentials for a production-based application.
However, it is a good practice to use IAM Roles.
For more information on IAM Roles, please visit the following URL:
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.htmlThe most secure and recommended method for granting an application running on an Amazon EC2 instance access to AWS APIs is to assign IAM roles to the EC2 instances. Therefore, the correct answer is D.
Here is a more detailed explanation of the four options:
A. Passing API credentials to the instance using instance userdata: This is not a recommended method as userdata is not secure and can be intercepted. Also, passing credentials in clear text can be risky since anyone who can access the instance can potentially retrieve these credentials.
B. Storing API credentials as an object in Amazon S3: This is also not a recommended method since S3 is not secure by default, and anyone with access to the S3 bucket can retrieve the credentials. Additionally, accessing the S3 bucket will require the credentials, so you end up in a catch-22 situation.
C. Embedding the API credentials into your application: This method is also not secure as the credentials are embedded in clear text in the application code. Therefore, anyone who can access the application code can retrieve the credentials.
D. Assigning IAM roles to the EC2 instances: This is the most secure and recommended method as it does not require the application to store credentials at all. Instead, the application can make API calls using temporary security credentials obtained from the EC2 instance metadata service. IAM roles allow you to define a set of permissions for the EC2 instances that the application can use. These permissions are based on policies attached to the role. The instance retrieves these temporary credentials from the metadata service and uses them to make API calls on behalf of the application.
In summary, IAM roles are the recommended and most secure method of granting applications running on EC2 instances access to AWS APIs.