Explore! IAM User Region Specific Access Restrictions to AWS Services
Tags: aws, ec2instance, iamuser, iampolicy
Published: 2023-12-09 19:43:07

“ I have checked the documents of AWS to resolve the issue of region specific access restrictions to users. So I checked the solution and found out that it can be possible with the IAM policies condition option. Pricing of Amazon EC2 depends on usage of instance and IAM includes no costs.”

AWS Identity and Access Management (IAM) provides fine-grained access control across all of AWS. With IAM, you can specify who can access which services and resources, and under which conditions. With IAM policies, you manage permissions to your workforce and systems to ensure least-privilege permissions. IAM is an AWS service that is offered at no additional charge. To learn more, read the [IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html).

In this post, you will get to know how to explore! IAM user region specific access restrictions to aws services. Here I have used an ec2 server and iam policy which makes restrictions on IAM user region specific access.

#Prerequisites
You’ll need an Amazon EC2 Server for this post. [Getting started with amazon EC2](https://aws.amazon.com/ec2/getting-started/) provides instructions on how to launch an EC2 Server. For this blog, I assume that I have an ec2 server created in N.Virginia and Oregon region.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgl1kuo08gijaypzx1bh.jpg)
The architecture diagram shows the overall deployment architecture with data flow, amazon ec2 and IAM User.

#Solution overview
The blog post consists of the following phases:
1. Create IAM User with Required Policy and Verify the User Login
2. Update of IAM Policy with Region Restrict Permission and Verify the User Access for EC2

I have a ec2 server in N.Virginia and a ec2 server in Oregon region as below →
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2qzs3xkbujxm824n1x0d.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k1m2yi14mck5u7kbe0du.png)

##Phase 1: Create IAM User with Required Policy and Verify the User Login 
1. Open the IAM console and create an IAM user with required policy. Also login with IAM user credentials and verify the ec2 instance visibility in N.Virginia and Oregon region.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cku22b3n9a5fd35tgswt.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ydxwfbwmb7prbe2ocfra.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j24ul1ycd3ttc81slkub.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddccokundv2lu0xlkvp2.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gju4jbvlx7i06addpk97.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7eko5uo2y4k4znrs9kv.png)

##Phase 2: Update of IAM Policy with Region Restrict Permission and Verify the User Access for EC2

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj5tpdtiyn1tegvofkl7.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1a8lp47rznqvnpmug96a.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lhw74ir9e08qgdipny7a.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5gmtuesvw1t29eex4wpm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr272b211hwdp8x03dhu.png)

#Clean-up
Delete EC2 Instances, IAM User and IAM Policy.

#Pricing
I review the pricing and estimated cost of this example. 

Cost of EC2 Instance = $0.18

Cost of IAM = $0.0

Total Cost = $(0.18 + 0.0) = $0.18

#Summary
In this post, I showed “how to explore! IAM user region specific access restrictions to aws services”.

For more details on IAM, Checkout Get started IAM, open the [IAM console](https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/home). To learn more, read the [IAM documentation](https://docs.aws.amazon.com/iam/).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)