A comprehensive Infrastructure as Code solution for managing Cisco Meraki dashboard administrators with automated security monitoring and compliance reporting.
|
|
|
|
Simple workflow: CSV Data β Terraform β Meraki API β Security Analysis β Web Dashboard
Before you begin, ensure you have:
- Terraform >= 1.0 installed (Download)
- Python 3.6+ with pip (Download)
- Meraki Dashboard API Key with organization admin privileges
- Basic knowledge of CSV files and command line
# Clone or download this repository
git clone https://github.com/yourusername/meraki-admin-security-tool.git
cd meraki-admin-security-tool
# Install Python dependencies
pip install requests
# Initialize Terraform
terraform init# Set your Meraki API key (recommended)
export MERAKI_API_KEY="your_api_key_here"
# OR create terraform.tfvars file
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your API keyEdit admins.csv with your administrator details:
email,permission_level,organization_id
[email protected],full,123456
[email protected],read-only,123456
[email protected],full,654321
[email protected],read-only,654321
# Preview changes
terraform plan
# Apply configuration
terraform apply# Export data for dashboard
./export_outputs.sh
# Start web server (optional)
cd web_ui
python3 -m http.server 8080
# Open http://localhost:8080/dashboard.html- Total Administrators - Complete count across all organizations
- High-Risk Administrators - Immediate attention required
- 2FA Compliance - Two-factor authentication adoption rate
- API Usage Status - Active vs. inactive API users
- Critical Security Risks - Administrators requiring immediate attention
- Detailed Risk Reasons - Specific security concerns explained
- Compliance Status - Visual indicators for quick assessment
- Actionable Recommendations - Clear next steps for remediation
- Complete Administrator List - All administrators with security details
- Permission Tracking - Current access levels and organization assignments
- Activity Monitoring - Last API usage and activity timestamps
- Security Status - Visual indicators for 2FA, API keys, and risk level
# Required: Meraki API Key
export MERAKI_API_KEY="your_meraki_api_key"
# Optional: Debug mode
export TF_LOG=DEBUG
# Optional: Custom CSV file location
export TF_VAR_admins_csv_file="custom_admins.csv"| Variable | Description | Default | Example |
|---|---|---|---|
meraki_api_key |
Meraki Dashboard API Key | null |
"abc123..." |
admins_csv_file |
Path to administrators CSV | "admins.csv" |
"data/admins.csv" |
api_inactivity_threshold_days |
Days before flagging inactive API usage | 30 |
45 |
The administrators CSV file requires these columns:
- email (required): Administrator email address
- permission_level (required):
fullorread-only - organization_id (required): Target Meraki organization ID
Example CSV Format:
email,permission_level,organization_id
[email protected],full,123456
[email protected],read-only,123456
[email protected],full,654321
The tool automatically identifies administrators who pose security risks:
- 2FA Not Enabled - Missing two-factor authentication
- Dormant API Keys - Have API access but haven't used it recently
- Inactive Administrators - No API activity beyond threshold period
- Permission Mismatches - Inappropriate access levels
# Example security validation
is_high_risk = (
not two_factor_enabled or
(has_api_key and last_usage > 30_days_ago) or
(has_api_key and never_used_api)
)- 2FA Adoption Rate - Percentage of administrators with 2FA enabled
- API Usage Statistics - Active vs. inactive API key holders
- Risk Distribution - Breakdown of security risk categories
- Trend Analysis - Historical compliance data (with regular runs)
Create .github/workflows/security-check.yml:
name: Daily Security Check
on:
schedule:
- cron: '0 9 * * *' # Daily at 9 AM
workflow_dispatch:
jobs:
security-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Run Security Assessment
env:
MERAKI_API_KEY: ${{ secrets.MERAKI_API_KEY }}
run: |
terraform init
terraform apply -auto-approve
./export_outputs.sh
- name: Upload Security Report
uses: actions/upload-artifact@v3
with:
name: security-report
path: web_ui/terraform_outputs.json# Add to crontab for daily checks
0 9 * * * cd /path/to/project && terraform apply -auto-approve && ./export_outputs.shAutomated Workflow: Schedule β Security Scan β Risk Assessment β Report Generation β Notification
email,permission_level,organization_id
[email protected],full,123456
[email protected],read-only,654321
[email protected],full,789012
# terraform.tfvars
api_inactivity_threshold_days = 45 # Custom threshold# Export data for external processing
terraform output -json > security_data.json
# Send to monitoring system
curl -X POST -H "Content-Type: application/json" \
-d @security_data.json \
https://your-monitoring-system.com/api/security-reports# Solution: Add delays between operations
export TF_LOG=DEBUG
terraform apply
# Check rate limit status
curl -H "X-Cisco-Meraki-API-Key: $MERAKI_API_KEY" \
https://api.meraki.com/api/v1/organizations# Verify API key permissions
terraform output admin_summary
# Check organization access
curl -H "X-Cisco-Meraki-API-Key: $MERAKI_API_KEY" \
"https://api.meraki.com/api/v1/organizations/YOUR_ORG_ID/admins"# Validate CSV format
python3 -c "import csv; print(list(csv.DictReader(open('admins.csv'))))"Enable detailed debug output for troubleshooting:
export TF_LOG=DEBUG
terraform apply| Metric | Small Org | Medium Org | Large Org |
|---|---|---|---|
| Administrators | 1-10 | 11-100 | 100+ |
| Execution Time | <30s | 1-3 min | 3-10 min |
| Memory Usage | <50MB | 50-200MB | 200MB+ |
| API Calls | 10-20 | 50-150 | 200+ |
# Parallel execution for large deployments
terraform apply -parallelism=10
# Reduced API calls with caching
export TF_LOG=WARN # Reduce logging overhead- Store API keys as environment variables only
- Never commit API keys to version control
- Use secure credential management in production
- Regularly rotate API keys
- Limit API key permissions to required organizations
- Implement proper file permissions (600) for sensitive files
- Use HTTPS for all API communications
- Enable audit logging for all changes
# Secure file permissions
chmod 600 terraform.tfvars
chmod 600 *.tfstate
chmod +x scripts/*.pyWe welcome contributions!
# Fork and clone repository
git clone https://github.com/yourusername/meraki-admin-security-tool.git
cd meraki-admin-security-tool
# Install development dependencies
pip install requests pytest
# Run tests
terraform validate
python3 -m pytest tests/ (if tests exist)
# Format code
terraform fmtHave an idea? Create a discussion or open an issue!
Popular requested features:
- Slack/Teams notifications
- PDF report generation
- Historical trend analysis
- Custom security policies
- SSO integration
- Multi-tenant dashboard
- Email alerting system
- Custom compliance rules
# View security summary
terraform output admin_security_report
# Check risky administrators
terraform output risky_admins_alert
# View compliance metrics
terraform output two_factor_compliance
# API usage statistics
terraform output api_usage_summary{
"risky_admins_alert": {
"count": 2,
"message": "Security risks detected",
"details": {
"[email protected]": {
"email": "[email protected]",
"organization_id": "123456",
"reasons": ["2FA not enabled", "Has API key but never used APIs"]
}
}
}
}meraki-admin-security-tool/
βββ README.md # This file
βββ LICENSE # MIT License
βββ main.tf # Main Terraform configuration
βββ variables.tf # Variable definitions
βββ outputs.tf # Output definitions
βββ terraform.tfvars.example # Example variables file
βββ admins.csv # Administrator definitions
βββ export_outputs.sh # Export script for web UI
βββ scripts/
β βββ check_2fa_status.py # Security monitoring script
βββ web_ui/
β βββ dashboard.html # Professional security dashboard
βββ docs/
βββ INSTALLATION.md # Detailed installation guide
βββ TROUBLESHOOTING.md # Common issues and solutions
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License - Feel free to use, modify, and distribute
Commercial use β
| Private use β
| Modification β
| Distribution β
- Cisco DevNet for the excellent Meraki Terraform provider
- HashiCorp for Terraform and comprehensive documentation
| Type | Link | Description |
|---|---|---|
| π Documentation | Wiki | Detailed guides and examples |
| π Bug Reports | Issues | Report bugs and request features |
| π¬ Discussions | Discussions | Ask questions and share ideas |
| π§ Contact | Direct support contact |
β If this tool helps you manage Meraki administrators more securely, please star the repository!
Made with β€οΈ for the Cisco community
- By Udara Thenuwara