feat: Add cluster-level IAM security analysis (PR #3) #1460
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #[issue-number]
Summary
Changes
This PR adds cluster-level IAM security analysis to the ECS security analysis tool, implementing comprehensive checks for service-linked roles and IAM best practices.
Implementation:
_analyze_cluster_iam_security()
method (~145 lines) to analyze IAM configurationsSecurity Checks:
ECS Exec Service-Linked Role Verification (Medium severity)
AWSServiceRoleForECS
exists when ECS Exec is configuredCapacity Provider Service-Linked Role Validation (Medium severity)
General IAM Configuration Review (Low severity)
Code Changes:
awslabs/ecs_mcp_server/api/security_analysis.py
: +150 linesawslabs/ecs_mcp_server/modules/security_analysis.py
: +6 linestests/unit/test_security_analysis.py
: +246 lines, -9 linesUser experience
Before this change:
After this change:
Example output:
🟡 Verify ECS Service-Linked Role Configuration Severity: Medium | Category: IAM | Resource: my-cluster
Issue: Cluster has ECS Exec configured, which requires the AWSServiceRoleForECS service-linked role. Verify it exists and has correct permissions.
Remediation:
Check if the service-linked role exists:
aws iam get-role --role-name AWSServiceRoleForECS
If missing, create it:
aws iam create-service-linked-role --aws-service-name ecs.amazonaws.com
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change? N
RFC issue number: N/A
Related PRs:
Testing:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.