agentleFS
jimmypocockjimmypocock/cursor-rules/.cursor/rules/aws-iam.mdc

cursor-rules / rules

Cursor rule8 starsChanged 19 months agoMITView on GitHub

AWS IAM Security Best Practices

The file

Show its rules and text

We split this aws-iam.mdc into the rules it gives an agent

30 rules. About 0 are common, 30 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈30

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use specific ARNs instead of wildcards when possible

    line 18
  2. Distinctive:

    Add conditions to further restrict access when appropriate

    line 19
  3. Distinctive:

    Use policy variables to make policies more precise

    line 22
  4. Distinctive:

    Create purpose-specific roles for different functions

    line 26
  5. Distinctive:

    Use role paths to organize roles by application or service

    line 29
  6. Distinctive:

    Document purpose and usage of each role

    line 31
  7. Distinctive:

    Create function-specific IAM roles

    line 36
  8. Distinctive:

    Use resource-based conditions for additional security

    line 38
  9. Distinctive:

    Add X-Ray permissions if tracing is enabled

    line 40
  10. Distinctive:

    Document all permissions in comments or metadata

    line 42
  11. Distinctive:

    Follow the same-account principle for resource access

    line 43
  12. Distinctive:

    Use resource policies to control API access

    line 46
  13. Distinctive:

    Create API-specific roles for Lambda integrations

    line 48
  14. Distinctive:

    Use IAM tags for access control when appropriate

    line 52
  15. Distinctive:

    Use IAM policy conditions for attribute-level security

    line 58
  16. Distinctive:

    Create separate roles for read and write operations

    line 59
  17. Distinctive:

    Document access patterns in IAM policy comments

    line 63
  18. Distinctive:

    Use specific resource ARNs for object access

    line 67
  19. Distinctive:

    Use bucket policies in conjunction with IAM policies

    line 71
  20. Distinctive:

    Use AWS managed policies as a starting point

    line 78
  21. Distinctive:

    Create custom policies for specific requirements

    line 79
  22. Distinctive:

    Use IAM Access Analyzer to identify issues

    line 81
  23. Distinctive:

    Use cross-stack references for shared IAM resources

    line 88
  24. Distinctive:

    Document policy decisions in code comments

    line 90
  25. Distinctive:

    Use IAM policy templates for consistent patterns

    line 92
  26. Distinctive:

    Use IAM roles instead of long-term access keys

    line 96
  27. Distinctive:

    Create processes for emergency access

    line 99
  28. Distinctive:

    Use session tags for dynamic permissions

    line 101
  29. Distinctive:

    Use IAM Access Analyzer to identify unintended access

    line 109
  30. Distinctive:

    Create dashboards for permission usage

    line 110

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
aws-iam.mdc
---
description: AWS IAM Security Best Practices
globs: 
alwaysApply: false
---
---
Description: AWS IAM Security Best Practices
Globs: **/iam/**/*.ts, **/iam/**/*.json, **/cdk/**/*.ts, **/sam/**/*.yaml, **/cloudformation/**/*.yaml
---

# AWS IAM Development Standards
@base.mdc
@typescript.mdc

## IAM Policy Design
- Apply the principle of least privilege for all IAM roles and policies
- Grant only the minimum permissions necessary for the required task
- Use specific ARNs instead of wildcards when possible
- Add conditions to further restrict access when appropriate
- Separate permissions by function or service
- Review and audit IAM policies regularly
- Use policy variables to make policies more precise
- Implement resource-based policies where applicable

## IAM Role Structure
- Create purpose-specific roles for different functions
- Assign appropriate trust relationships to roles
- Set appropriate session durations for assumed roles
- Use role paths to organize roles by application or service
- Implement proper cross-account role access patterns
- Document purpose and usage of each role
- Organize roles using proper naming conventions
- Apply strict permission boundaries for delegated permissions

## Lambda Function IAM Roles
- Create function-specific IAM roles
- Grant only permissions needed by the specific Lambda function
- Use resource-based conditions for additional security
- Include CloudWatch Logs permissions for proper logging
- Add X-Ray permissions if tracing is enabled
- Implement resource-level permissions when possible
- Document all permissions in comments or metadata
- Follow the same-account principle for resource access

## API Gateway IAM Integration
- Use resource policies to control API access
- Implement proper IAM authentication for private APIs
- Create API-specific roles for Lambda integrations
- Separate roles for different API stages
- Include proper CloudWatch Logs permissions
- Implement custom authorizers with appropriate permissions
- Use IAM tags for access control when appropriate
- Apply API key restrictions correctly

## DynamoDB Access Control
- Grant specific table-level permissions for operations
- Implement fine-grained access control using IAM conditions
- Use IAM policy conditions for attribute-level security
- Create separate roles for read and write operations
- Implement proper access controls for DynamoDB streams
- Apply IAM conditions for specific key-based access
- Restrict access to specific indexes when applicable
- Document access patterns in IAM policy comments

## S3 Bucket Policies
- Implement least privilege for bucket access
- Use specific resource ARNs for object access
- Apply proper conditions for public content when needed
- Leverage VPC endpoint policies for private access
- Implement IAM roles for cross-account access
- Use bucket policies in conjunction with IAM policies
- Apply proper encryption requirements in policies
- Implement S3 Object Ownership correctly

## Security Best Practices
- Enable and enforce MFA for critical operations
- Implement proper key rotation for access keys
- Use AWS managed policies as a starting point
- Create custom policies for specific requirements
- Implement proper credential management
- Use IAM Access Analyzer to identify issues
- Implement Service Control Policies for organization-wide controls
- Monitor and alert on policy changes and unusual access patterns

## Infrastructure as Code
- Define IAM resources using CloudFormation, SAM, or CDK
- Parameterize environment-specific values
- Use cross-stack references for shared IAM resources
- Implement proper resource naming conventions
- Document policy decisions in code comments
- Validate IAM policy correctness before deployment
- Use IAM policy templates for consistent patterns
- Implement proper drift detection for IAM resources

## Temporary Credentials
- Use IAM roles instead of long-term access keys
- Implement proper AssumeRole patterns
- Set appropriate permission boundaries
- Create processes for emergency access
- Implement proper role chaining for multi-account access
- Use session tags for dynamic permissions
- Apply proper service-linked role usage
- Implement role assumption monitoring

## Auditing and Monitoring
- Enable AWS CloudTrail for API activity monitoring
- Set up alerts for sensitive IAM changes
- Implement regular access reviews
- Use IAM Access Analyzer to identify unintended access
- Create dashboards for permission usage
- Monitor unused permissions and access keys
- Implement proper IAM credential reporting
- Track and alert on policy version changes

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.