---
title: Instance roles should be used for AWS resource access from instances
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Instance roles should be used for AWS
  resource access from instances
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Instance roles should be used for AWS resource access from instances
 
## Description{% #description %}

AWS EC2 instances should use IAM roles, delivered through an attached IAM instance profile, to access AWS resources instead of embedded credentials. IAM roles provide temporary, automatically rotated credentials, reducing the risk of credential exposure and unauthorized access. This rule fails instances that have no IAM instance profile associated, or whose instance profile contains no role. An instance profile that was not collected is not judged, and instances that are shutting down or terminated are skipped.

## Remediation{% #remediation %}

1. Create an IAM role for Amazon EC2 that grants only the permissions the instance requires, as described in [IAM roles for Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html).
1. Attach the role to each instance that has no instance profile or whose instance profile has no role. See [Attach an IAM role to an instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/attach-iam-role.html).

## References{% #references %}

- [IAM roles for Amazon EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html)
- [Attach an IAM role to an instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/attach-iam-role.html)
- [Using instance profiles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html)
- [associate-iam-instance-profile CLI reference](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-iam-instance-profile.html)
- [CIS Amazon Web Services Benchmarks](https://www.cisecurity.org/benchmark/amazon_web_services)
