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 -h
git clone https://github.com/yourusername/hawkling.git
cd hawkling
go build -o hawkling ./cmd/hawkling
Hawkling 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-1
Options:
-o, --output
- Output format:table
orjson
(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-run
Options:
--dry-run
- Simulate deletion without actually deleting--force
- Delete without confirmation
hawkling prune --days 90
hawkling prune --days 90 --force
Options:
--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 production
hawkling list --all
hawkling list --used
hawkling list --output json
hawkling list --days 180
hawkling delete OldServiceRole
hawkling delete OldServiceRole --force
hawkling prune --days 30 --dry-run
Hawkling 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/hawkling
go test ./...