# Create EC2 IAM Role with Policy Guide

![Create IAM Role for EC2 with Policy Attachment](https://cdn.hashnode.com/res/hashnode/image/upload/v1728373595038/0f1e9eba-24ab-4afd-95d5-eb5114492180.png?w=1600\&h=840\&fit=crop\&crop=entropy\&auto=compress,format\&format=webp)

### Create IAM Role for EC2 with Policy Attachment

### How to Set Up an IAM Role for EC2 and Attach a Policy

### Table of contents

* [Tasks](https://abisec.gitbook.io/devsecops/aws/broken-reference)
* [Steps](https://abisec.gitbook.io/devsecops/aws/broken-reference)

#### Tasks <a href="#heading-tasks" id="heading-tasks"></a>

Create an IAM role as below:

* IAM role name must be `iamrole_javed`.
* Entity type must be `AWS Service` and use case must be `EC2`.
* Attach a policy named `iampolicy_javed`.

#### Steps <a href="#heading-steps" id="heading-steps"></a>

1. IAM → Roles → Create role now
2.

```
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728374357710/47b519d0-11a5-4ded-b524-5eb2e2b4e313.png?auto=compress,format\&format=webp)
```

```
Trusted entity type → AWS Service | Service or use case → EC2
```

3\.

```
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728374424897/588cacd4-6983-4dd0-a871-b951fac53074.png?auto=compress,format\&format=webp)

Add permissions and Role name → iamrole\_javed
```

4\.

```
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728374717385/b38a0cb4-0de6-4b8c-a0c1-1c417849765e.png?auto=compress,format\&format=webp)

**Create Role** now
```

5\.

```
![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728374781464/aa462d31-7b2e-41f0-8c33-da890229a5eb.png?auto=compress,format\&format=webp)

**Role iamrole\_javed is created.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1728374828400/1dd39096-6a6f-4c64-90b6-5385b3442f09.png?auto=compress,format\&format=webp)

\#happylearning #aws #cloudcomputing
```
