
Ultimate access to all questions.
Deep dive into the quiz with AI chat providers.
We prepare a focused prompt with your quiz and certificate details so each AI can offer a more tailored, in-depth explanation.
A company uses Amazon EC2 instances to host its internal systems. As part of a deployment operation, an administrator tries to use the AWS CLI to terminate an EC2 instance. However, the administrator receives a 403 (Access Denied) error message.
The administrator is using an IAM role that has the following IAM policy attached:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ec2:TerminateInstances"],
"Resource": ["*"]
},
{
"Effect": "Deny",
"Action": ["ec2:TerminateInstances"],
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"192.0.2.0/24",
"203.0.113.0/24"
]
}
},
"Resource": ["*"]
}
]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ec2:TerminateInstances"],
"Resource": ["*"]
},
{
"Effect": "Deny",
"Action": ["ec2:TerminateInstances"],
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"192.0.2.0/24",
"203.0.113.0/24"
]
}
},
"Resource": ["*"]
}
]
}
What is the cause of the unsuccessful request?
A
The EC2 instance has a resource-based policy with a Deny statement.
B
The principal has not been specified in the policy statement.
C
The "Action" field does not grant the actions that are required to terminate the EC2 instance.
D
The request to terminate the EC2 instance does not originate from the CIDR blocks 192.0.2.0/24 or 203.0.113.0/24.
Explanation:
The correct answer is D because:
Policy Analysis: The IAM policy contains two statements:
ec2:TerminateInstances on all resources ("*")ec2:TerminateInstances with a condition NotIpAddress for the source IPCondition Logic: The condition "NotIpAddress": { "aws:SourceIp": ["192.0.2.0/24", "203.0.113.0/24"] } means:
IAM Evaluation Logic: In AWS IAM:
Why Other Options Are Incorrect:
ec2:TerminateInstances, which is the correct actionKey Takeaway: When using IP-based conditions in IAM policies, ensure the request originates from the allowed IP ranges. The NotIpAddress condition combined with Deny effect creates a whitelist where only requests from specified IPs are allowed.