Triage and Remediation
How to Prevent
Using Console
Using Console
To prevent Role Service Inactivity in IAM using the AWS Management Console, follow these steps:
-
Enable Access Advisor:
- Navigate to the IAM dashboard in the AWS Management Console.
- Select the “Roles” tab.
- Choose the specific role you want to monitor.
- Go to the “Access Advisor” tab to review the services that the role has accessed and the last accessed time.
- Regularly review this information to identify and take action on inactive roles.
-
Set Up CloudWatch Alarms:
- Go to the CloudWatch dashboard.
- Create a new alarm based on IAM metrics.
- Set the alarm to trigger if a role has not been used for a specified period.
- Configure notifications to alert administrators when the alarm is triggered.
-
Enable AWS Config Rules:
- Navigate to the AWS Config dashboard.
- Ensure that AWS Config is enabled in your account.
- Add a managed rule such as
iam-role-last-used
to monitor the last time an IAM role was used. - Set up notifications for compliance changes to be alerted when a role becomes inactive.
-
Implement IAM Role Policies:
- Go to the IAM dashboard and select the “Roles” tab.
- Choose the role you want to configure.
- Attach a policy that includes conditions to limit the role’s permissions based on time or usage.
- Use the
aws:RequestTag
oraws:PrincipalTag
conditions to enforce policies that disable or restrict roles after a period of inactivity.
Using CLI
Using CLI
To prevent Role Service Inactivity in IAM using AWS CLI, you can follow these steps:
-
Create a Role with Specific Permissions:
Ensure that the role you create has the necessary permissions and is not overly permissive. Use the
create-role
command to create a role with a specific policy. -
Attach a Policy to the Role:
Attach a policy to the role that grants only the necessary permissions. Use the
attach-role-policy
command to attach a managed policy orput-role-policy
to attach an inline policy. -
Enable CloudTrail to Monitor Role Activity:
Enable AWS CloudTrail to monitor and log all activities associated with the role. This helps in identifying any inactivity or misuse.
-
Set Up CloudWatch Alarms for Inactivity:
Create CloudWatch Alarms to monitor the role’s activity and trigger alerts if the role is inactive for a specified period.
Using Python
Using Python
To prevent Role Service Inactivity in IAM using Python scripts, you can follow these steps:By following these steps, you can effectively prevent role service inactivity in IAM using Python scripts.