Step 1: Install Boto3
Ensure you have the Boto3 library installed. You can install it using pip if you haven’t already:
Copy
Ask AI
pip install boto3
Step 2: List Users and Check for Inline Policies
Use the following script to list all IAM users and check if they have any inline policies. If they do, you can log or take appropriate action.
Copy
Ask AI
import boto3# Initialize a session using Amazon IAMiam = boto3.client('iam')# List all IAM usersusers = iam.list_users()for user in users['Users']: user_name = user['UserName'] # List inline policies for each user inline_policies = iam.list_user_policies(UserName=user_name) if inline_policies['PolicyNames']: print(f"User {user_name} has inline policies: {inline_policies['PolicyNames']}") # Take appropriate action, e.g., notify, log, or remove the inline policies
Step 2: List Users and Check for Inline Policies
Use the following script to list all users and check if they have any inline policies.
Copy
Ask AI
from azure.identity import DefaultAzureCredentialfrom azure.mgmt.authorization import AuthorizationManagementClient# Initialize credentials and clientcredential = DefaultAzureCredential()subscription_id = 'your-subscription-id'client = AuthorizationManagementClient(credential, subscription_id)# List all users (service principals)users = client.service_principals.list()for user in users: user_id = user.object_id # List role assignments for each user role_assignments = client.role_assignments.list_for_scope(f'/subscriptions/{subscription_id}/providers/Microsoft.Authorization/servicePrincipals/{user_id}') for role_assignment in role_assignments: if role_assignment.properties.role_definition_id: print(f"User {user.display_name} has role assignments: {role_assignment.properties.role_definition_id}") # Take appropriate action, e.g., notify, log, or remove the inline policies
Step 1: Install Google Cloud IAM Library
Ensure you have the Google Cloud IAM library installed:
Copy
Ask AI
pip install google-cloud-iam
Step 2: List Users and Check for Inline Policies
Use the following script to list all users and check if they have any inline policies.
Copy
Ask AI
from google.cloud import iam_v1# Initialize the IAM clientclient = iam_v1.IAMClient()# List all service accounts (users)project_id = 'your-project-id'service_accounts = client.list_service_accounts(name=f'projects/{project_id}')for account in service_accounts.accounts: account_name = account.name # Get IAM policy for each service account policy = client.get_iam_policy(resource=account_name) for binding in policy.bindings: if 'serviceAccount' in binding.members: print(f"Service Account {account.email} has roles: {binding.role}") # Take appropriate action, e.g., notify, log, or remove the inline policies