# 1.17 Ensure IAM instance roles are used for AWS resource access from instances (Automated)

- Source: https://support.icompaas.com/support/solutions/articles/62000234212-1-17-ensure-iam-instance-roles-are-used-for-aws-resource-access-from-instances-automated-
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [CIS Amazon Web Services Foundations Benchmark v5.0.0](https://support.icompaas.com/support/solutions/62000112684) › [CIS AWS Benchmarks](https://support.icompaas.com/support/solutions/folders/62000169233)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

#### **Profile Applicability**

-   **Level 1**

#### **Description:**

IAM instance roles allow EC2 instances to securely access AWS resources, such as S3 buckets, DynamoDB tables, and other services, without needing hard-coded credentials. By assigning IAM roles to EC2 instances, the instances can use temporary security credentials to access resources, ensuring that credentials are not exposed or compromised.

This practice eliminates the need to store AWS access keys or secret keys within the EC2 instance, providing a more secure way to manage permissions and access to resources. Ensuring that IAM instance roles are used for AWS resource access from EC2 instances is a fundamental security best practice to prevent accidental exposure of credentials and to enhance the security posture of your environment.

#### **Rationale:**

Using IAM instance roles to manage EC2 access to AWS resources provides:

-   Security: Prevents the need to hard-code AWS credentials into EC2 instances, reducing the risk of credential exposure.  
    
-   Simplicity: Simplifies access management by using IAM roles instead of managing access keys and secret keys manually.  
    
-   Temporary credentials: IAM roles provide temporary security credentials that are automatically rotated, further reducing the risk of key exposure.  
    
-   Compliance: Helps meet regulatory and security standards by ensuring that credentials are not stored in EC2 instances and are managed securely.  
    

Without IAM instance roles, hard-coded access keys may be exposed, leading to potential security risks and non-compliance with best practices.

#### **Impact:**

Failure to use IAM instance roles for resource access can result in:

-   Exposed credentials: Hard-coded AWS access keys may be exposed in application code or EC2 instance metadata.  
    
-   Increased security risks: Storing access keys directly on EC2 instances increases the attack surface and the potential for unauthorized access to AWS resources.  
    
-   Non-compliance: Failing to use instance roles may violate security best practices and regulatory compliance requirements.  
    

By using IAM instance roles, organizations can ensure secure access to AWS resources while adhering to the principle of least privilege.

#### **Default Value:**

By default, EC2 instances do not have IAM roles attached, meaning they will not automatically have permissions to access AWS resources unless an IAM role is explicitly assigned.

#### **Pre-Requisites:**

-   AWS CLI installed and configured  
    
-   IAM permissions:  
    
    -   iam:AttachRolePolicy  
        
    -   iam:ListRoles  
        
    -   iam:PassRole  
        
-   EC2 instances must be configured to use IAM roles for accessing AWS resources  
    

#### **Remediation:**

##### **Test Plan:**

**Using AWS Console:**

1.  Go to the [EC2 Console](https://console.aws.amazon.com/ec2/).  
    
2.  Check the IAM role assigned to the EC2 instances in the Instances section under Instance details.  
    
3.  Ensure that the EC2 instances have an IAM role assigned with the necessary permissions to access required AWS resources.  
    
4.  If no role is assigned or an inappropriate role is assigned, modify the instance settings to assign the correct IAM role.  
    

**Using AWS CLI:**

aws ec2 describe-instances --instance-ids <instance-id> --query "Reservations\[\*\].Instances\[\*\].IamInstanceProfile" --output table

To verify the IAM role assigned to an instance:

aws ec2 describe-instances --instance-ids <instance-id> --query "Reservations\[\*\].Instances\[\*\].IamInstanceProfile.Arn" --output table

  

##### **Implementation Plan:**

**Using AWS Console:**

1.  Assign an IAM role to an EC2 instance:  
    
    -   Go to the [EC2 Console](https://console.aws.amazon.com/ec2/).  
        
    -   Select the EC2 instance you wish to modify.  
        
    -   Under Actions, select Security, then Modify IAM Role.  
        
    -   Choose an appropriate IAM role from the drop-down menu and click Update IAM role.  
        
2.  Verify the role assignment:  
    
    -   Ensure that the IAM role is listed under Instance details in the EC2 instance settings.  
        

**Using AWS CLI:**

1.  Assign an IAM role to an EC2 instance:  
    

aws ec2 associate-iam-instance-profile --instance-id <instance-id> --iam-instance-profile Name=<role-name>

2.  Verify the IAM role:  
    

aws ec2 describe-instances --instance-ids <instance-id> --query "Reservations\[\*\].Instances\[\*\].IamInstanceProfile.Arn" --output table

#### **Backout Plan:**

#### **Using AWS Console:**

1.  If assigning the IAM role causes issues with resource access:  
    
    -   Go to the [EC2 Console](https://console.aws.amazon.com/ec2/).  
        
    -   Select the EC2 instance and remove the IAM role by selecting Actions, then Security, and Modify IAM Role.  
        
    -   Choose None and save the changes.  
        
2.  Review the IAM role's permissions if access to specific resources is denied, and adjust permissions accordingly.  
    

**Using AWS CLI:**

1.  Remove the IAM role from the EC2 instance:  
    

aws ec2 disassociate-iam-instance-profile --instance-id <instance-id>

2.  Stop or restart the instance if necessary to apply changes:  
    

aws ec2 stop-instances --instance-ids <instance-id>

aws ec2 start-instances --instance-ids <instance-id>

3.  Reassign the correct IAM role once issues are resolved:  
    

aws ec2 associate-iam-instance-profile --instance-id <instance-id> --iam-instance-profile Name=<role-name>

#### **References:**

-   [AWS EC2 IAM Role Documentation  
    ](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html)
    
-   [AWS IAM Documentation  
    ](https://docs.aws.amazon.com/IAM/latest/UserGuide/)
    
-   [AWS CLI Command Reference for EC2  
    ](https://docs.aws.amazon.com/cli/latest/reference/ec2/)
    

#### **CIS Controls Mapping:**

<table style="border:none;border-collapse:collapse"><tbody><tr style="height:39.25pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;"><strong>CIS Control Version</strong></span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;text-align:justify;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;"><strong>Control ID</strong></span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;text-align:justify;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;"><strong>Control Description</strong></span></span></span></p></td></tr><tr style="height:39.25pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">CIS v8</span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">4.9</span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">Perform Continuous Security Monitoring and Incident Detection</span></span></span></p></td></tr><tr style="height:25pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">CIS v7</span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">6.3</span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">Monitor Security Configurations for Compliance</span></span></span></p></td></tr><tr style="height:39.25pt"><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">CIS v7</span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word;font-family:&quot;Helvetica Neue&quot;;font-size:14px"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;font-family:&quot;Helvetica Neue&quot;;font-size:14px;text-align:justify"><span style="font-size:14px"><span style="font-family:Helvetica Neue"><span style="color:rgb(0, 0, 0);font-family:&quot;Helvetica Neue&quot;">5.2</span></span></span></p></td><td style="padding:5pt;overflow:hidden;overflow-wrap:break-word"><p dir="ltr" style="line-height:1.38;margin-bottom:0pt;text-align:justify"><span style="font-family:&quot;Helvetica Neue&quot;;font-size:14px"><span dir="ltr" style="color:rgb(0, 0, 0);font-weight:400">Securely Manage and Monitor Cloud Accounts and Services</span></span></p></td></tr></tbody></table>

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
