How Does IAM Explicit Deny Affect EC2 Instance S3 Access?
An IAM role is attached to an Amazon EC2 instance that explicitly denies access to all Amazon S3 API actions. The EC2 instance credentials file specifies the IAM access key and secret access key, which allow full administrative access. Given that multiple modes of IAM access are present for this EC2 instance, which of the following is correct?
Community Votes
60% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The question is a trap designed to test whether you understand that the credential provider chain (which determines which credentials are used) is completely separate from IAM policy evaluation logic (which determines what those credentials can do). An explicit deny in any applicable policy will always block the action.
This question tests the interaction between the AWS credential provider chain and IAM policy evaluation logic on an EC2 instance. The community consensus confirms that an explicit deny in an IAM policy always overrides any allow, regardless of which credentials are ultimately used by the AWS CLI.
Many candidates choose C, incorrectly believing that the credentials file takes precedence in the provider chain and therefore its 'full administrative access' permissions override the IAM role's explicit deny. They confuse the order of credential *retrieval* with the rules of policy *evaluation*.
Community Discussion (5 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
This question tests two distinct but related AWS concepts: the AWS credential provider chain and IAM policy evaluation logic.
First, let's address the credential provider chain. When the AWS CLI or SDK runs on an EC2 instance, it looks for credentials in a specific order: environment variables, then the credentials file (~/.aws/credentials), and finally the EC2 instance profile (IAM role). In this scenario, because the credentials file exists and contains valid keys, the AWS CLI will indeed use those keys, not the IAM role's temporary credentials. This is where many candidates get tripped up, as noted by user Kb80 in the comments.
However, the critical part of this question is the second concept: IAM policy evaluation logic. Once the AWS CLI has selected a set of credentials (in this case, the ones from the credentials file), it makes an API call to S3. AWS then evaluates all policies attached to the identity associated with those credentials. The fundamental rule of IAM policy evaluation is that an explicit deny always wins. If any policy attached to the user whose keys are in the credentials file contains an explicit deny for S3 actions, that deny will block the request, regardless of any other allow statements in any other policies.
The question states that the IAM role attached to the EC2 instance explicitly denies S3 access. While the CLI might use the keys from the credentials file, the evaluation of those keys' permissions is what matters. If the user associated with those keys also has an explicit deny (or if the question implies the role's deny somehow applies to the session), the action is blocked. The key takeaway, as emphasized by tomchandler077 and Anandesh, is that an explicit deny is the ultimate trump card in IAM. It doesn't matter how many "Allow" policies you have; a single explicit deny will shut down access. Therefore, the EC2 instance will not be able to perform any S3 action, making D the correct answer.
Official Reference
Exam Strategy
When you see a question that mentions both an 'explicit deny' and an 'allow' (especially 'full admin access'), immediately think of the IAM policy evaluation logic. An explicit deny always overrides an allow, no matter the source of the allow. Don't get distracted by the credential provider chain details unless the question is specifically about which credentials are being used.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →