Do you know you can restrict the certain IP addresses to access AWS services to be accessed with a single policy.
In this quick tutorial you will learn Deny IP addresses using AWS IAM policy with IAM policy examples
Lets get started.
Prerequisites
- AWS account
- Permissions to create IAM Policy
Lets describe the below IAM Policy in the AWS Cloud.
- Version is Policy version which is fixed.
- Effect is Deny in statement as we don’t want to allow IP addresses be able to Access AWS cloud.
- Resources are * wild character as we want action to be allowed for all AWS services.
- This policy deny all the IP address to access AWS cloud except few IP addresses using the NotIpAddress Condition and aws:ViaAWSService which is used to limit access to an AWS service makes a request to another service on your behalf.
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"192.0.2.0/24",
"203.0.113.0/24"
]
},
"Bool": {"aws:ViaAWSService": "false"}
}
}
}
}
Conclusion
This tutorial demonstrated that if you need to deny IP addresses using AWS IAM policy with IAM policy examples.