Hawkling is a command-line tool for managing AWS IAM roles, with a focus on identifying and cleaning up unused roles. It provides functionality for listing all IAM roles, detecting unused roles, and safely deleting them either individually or in bulk.
- List all IAM roles in your AWS account
- Identify roles that haven't been used for a specified period
- Filter to show only used roles
- Safely delete individual roles with confirmation prompts
- Bulk delete unused roles with optional dry-run mode
- Support for different output formats (table or JSON)
curl -fsSL https://raw.githubusercontent.com/watany-dev/hawkling/main/script/install.sh |sh
hawkling -hgit clone https://github.com/yourusername/hawkling.git
cd hawkling
go build -o hawkling ./cmd/hawklingHawkling offers several commands with various options:
--profile- AWS profile to use (optional)--region- AWS region (defaults to us-east-1)
hawkling list --profile myprofile --region us-east-1Options:
-o, --output- Output format:tableorjson(default: table)--all- Show detailed information including ARN and creation date--used- Show only roles that have been used at least once--days- Number of days to consider a role as unused (0 to list all roles)
hawkling delete MyUnusedRole --dry-runOptions:
--dry-run- Simulate deletion without actually deleting--force- Delete without confirmation
hawkling prune --days 90
hawkling prune --days 90 --forceOptions:
--days- Number of days to consider a role as unused (default: 90)--dry-run- Simulate deletion without actually deleting--force- Delete without confirmation
hawkling list --profile productionhawkling list --allhawkling list --usedhawkling list --output jsonhawkling list --days 180hawkling delete OldServiceRolehawkling delete OldServiceRole --forcehawkling prune --days 30 --dry-runHawkling requires IAM permissions to list and delete roles. It's recommended to use it with an IAM user or role that has appropriate permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iam:ListRoles",
"iam:GetRole",
"iam:DeleteRole",
"iam:ListRolePolicies",
"iam:DeleteRolePolicy",
"iam:ListAttachedRolePolicies",
"iam:DetachRolePolicy"
],
"Resource": "*"
}
]
}- Go 1.19 or higher
- AWS SDK for Go v2
go build -o hawkling ./cmd/hawklinggo test ./...