agentleFS
aws-solutionsaws-solutions/konductor/skills/infra-validation/SKILL.md

infra-validation

Skill11 starsChanged 49 days agoApache-2.0View on GitHub

Validates AWS CDK and CloudFormation infrastructure code against AWS best practices, security standards, and Well-Architected principles. Use before deploying infrastructure changes. Detects security vulnerabilities, cost issues, and compliance gaps.

The file

Show its rules and text

We split this skill into the rules it gives an agent

101 rules. About 0 are common, 95 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈95

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 16
  2. Distinctive:

    When this skill is activated, use the following as your full instruction set for validating infrastructure code.

    line 30
  3. Distinctive:

    Use this exact format:

    line 80
  4. Distinctive:

    Before you read any files, search any directories, or analyze any code, you MUST:

    line 118
  5. Distinctive:

    IF NO: Stop immediately and ask using the template from the "CRITICAL: STOP AND READ THIS FIRST" section above

    line 121
  6. Distinctive:

    Encryption at Rest: All data stores (S3, DynamoDB, RDS, EBS) must have encryption enabled

    line 179
  7. Distinctive:

    Secrets Management: No hardcoded credentials, use Secrets Manager or Parameter Store

    line 183
  8. Distinctive:

    Public Access: No public S3 buckets, no public RDS instances, no open security groups

    line 184
  9. Distinctive:

    Verify encryption enabled for all S3 buckets (AWS managed or customer managed KMS)

    line 190
  10. Distinctive:

    Check DynamoDB tables have encryption enabled

    line 191
  11. Distinctive:

    Verify API Gateway uses TLS 1.2 or higher

    line 193
  12. Distinctive:

    Check IAM policies for wildcard permissions (Action: "_", Resource: "_")

    line 194
  13. Distinctive:

    Verify no hardcoded credentials in Lambda environment variables or configuration

    line 196
  14. Distinctive:

    Check S3 buckets have public access blocked

    line 197
  15. Distinctive:

    Verify VPC endpoints used for AWS service access where appropriate

    line 199
  16. Distinctive:

    Check Lambda timeout settings (> 5 minutes may indicate architectural issues)

    line 216
  17. Distinctive:

    Verify DynamoDB billing mode aligns with traffic patterns (steady = provisioned, spiky = on-demand)

    line 217
  18. Distinctive:

    Check for NAT Gateways in multiple AZs when single AZ sufficient for non-production

    line 219
  19. Distinctive:

    Verify RDS instance sizes match workload requirements

    line 220
  20. Distinctive:

    Check for unused Elastic IPs (not attached to instances)

    line 222
  21. Distinctive:

    Verify CloudFront used for static content delivery to reduce data transfer costs

    line 223
  22. Distinctive:

    Verify CloudWatch alarms configured for Lambda errors, throttling, duration

    line 241
  23. Distinctive:

    Check DynamoDB alarms for throttling, capacity utilization

    line 242
  24. Distinctive:

    Verify log retention policies set (not indefinite retention)

    line 244
  25. Distinctive:

    Check Lambda functions have dead letter queues configured

    line 245
  26. Distinctive:

    Verify DynamoDB point-in-time recovery enabled for production tables

    line 246
  27. Distinctive:

    Check RDS automated backups enabled with appropriate retention

    line 247
  28. Distinctive:

    Verify auto-scaling configured for DynamoDB, ECS, Lambda concurrency

    line 249
  29. Distinctive:

    Check resource tagging includes Environment, Application, Owner, CostCenter

    line 250
  30. Distinctive:

    Verify RDS instances deployed in multi-AZ configuration for production

    line 266
  31. Distinctive:

    Check load balancers span multiple availability zones

    line 267
  32. Distinctive:

    Verify API Gateway has throttling configured (rate limit, burst limit)

    line 269
  33. Distinctive:

    Check DynamoDB tables have on-demand backup or continuous backups

    line 270
  34. Distinctive:

    Verify S3 buckets have versioning enabled for critical data

    line 271
  35. Distinctive:

    Check Lambda functions have retry configuration and dead letter queues

    line 272
  36. Distinctive:

    Verify SQS queues have dead letter queues configured

    line 274
  37. Distinctive:

    Check for single points of failure (single NAT Gateway, single database)

    line 275
  38. Distinctive:

    Verify CloudFront used for static content delivery

    line 290
  39. Distinctive:

    Check API Gateway caching enabled for cacheable endpoints

    line 291
  40. Distinctive:

    Verify Lambda memory allocation appropriate for workload (not default 128MB)

    line 293
  41. Distinctive:

    Check for Lambda provisioned concurrency for latency-sensitive functions

    line 294
  42. Distinctive:

    Verify VPC endpoints used for AWS service access (S3, DynamoDB)

    line 295
  43. Distinctive:

    Check RDS read replicas configured for read-heavy workloads

    line 296
  44. Distinctive:

    Verify CloudFront compression enabled for text-based content

    line 298
  45. Distinctive:

    Check Lambda functions use ARM64 (Graviton) for cost and performance benefits

    line 299
  46. Distinctive:

    Verify constructs follow single responsibility principle

    line 316
  47. Distinctive:

    Check naming conventions consistent across resources

    line 317
  48. Distinctive:

    Verify CDK Nag integrated for security scanning

    line 319
  49. Distinctive:

    Check suppressions have clear justifications

    line 320
  50. Distinctive:

    Verify outputs exported for cross-stack references

    line 322
  51. Distinctive:

    Check for hardcoded values that should be parameters

    line 323
  52. Distinctive:

    Verify unit tests exist for custom constructs

    line 325
  53. Distinctive:

    Verify resources deployed in compliant AWS regions

    line 341
  54. Distinctive:

    Check CloudTrail enabled for all regions with log file validation

    line 342
  55. Distinctive:

    Verify KMS customer managed keys used for sensitive data encryption

    line 344
  56. Distinctive:

    Check data retention policies configured (S3 lifecycle, CloudWatch Logs retention)

    line 345
  57. Distinctive:

    Verify MFA required for privileged operations

    line 347
  58. Distinctive:

    Check sensitive data marked with appropriate tags

    line 348
  59. Distinctive:

    Verify encryption algorithms meet organizational standards

    line 350
  60. Distinctive:

    Improper Resource Sizing: Default sizes used without analysis

    line 360
  61. Distinctive:

    Missing Error Handling: No error handling in Lambda functions, Step Functions

    line 361
  62. Distinctive:

    Check Lambda functions using default memory (128MB) without justification

    line 371
  63. Distinctive:

    Verify error handling in Lambda functions (try/catch, error responses)

    line 372
  64. Distinctive:

    Check for missing caching opportunities (API Gateway, CloudFront)

    line 374
  65. Distinctive:

    Environment Variables: No secrets in environment variables

    line 385
  66. Distinctive:

    Update Policies: Update policies for auto-scaling groups, RDS instances

    line 428
  67. Distinctive:

    Verify deletion protection enabled for production databases

    line 436
  68. Distinctive:

    Check update policies configured for auto-scaling groups

    line 437
  69. Distinctive:

    Verify no circular dependencies between stacks

    line 439
  70. Distinctive:

    Check stack policies configured to prevent accidental resource deletion

    line 440
  71. Distinctive:

    Verify cross-stack references use exports/imports correctly

    line 442
  72. Distinctive:

    Check removal policies appropriate for environment

    line 443
  73. Distinctive:

    Verify rollback configuration defined for critical stacks

    line 445
  74. Distinctive:

    Verify you have received the required information:

    line 457
  75. Distinctive:

    If missing, ask the user using the format from "CRITICAL: Start Here" section

    line 462
  76. Distinctive:

    Use systematic discovery to find ALL resources:

    line 486
  77. Distinctive:

    Search for construct instantiations:

    line 501
  78. Very specific:

    For CloudFormation: Search for ALL AWS::IAM::Policy and AWS::IAM::Role resources

    line 521
  79. Very specific:

    For CDK: Search for all .addToRolePolicy() calls

    line 522
  80. Distinctive:

    Check EVERY IAM policy statement for:

    line 524
  81. Very specific:

    Search for: "Resource": "*" or resources: ["*"]

    line 527
  82. Very specific:

    Search for: "Resource": "arn:aws:*:*:*:*" patterns

    line 528
  83. Very specific:

    Search for: "Action": "service:*" (e.g., "s3:*")

    line 533
  84. Distinctive:

    Should specify exact actions needed

    line 537
  85. Very specific:

    Check for Principal with external account IDs

    line 540
  86. Distinctive:

    Verify trust relationships are intentional

    line 541
  87. Distinctive:

    Check EVERY data store resource:

    line 555
  88. Distinctive:

    Check for access logging on:

    line 622
  89. Distinctive:

    Check for alarms on:

    line 684
  90. Distinctive:

    Lambda Functions: - MUST have alarms for:

    line 686
  91. Distinctive:

    DynamoDB Tables: - MUST have alarms for:

    line 693
  92. Distinctive:

    API Gateway: - MUST have alarms for:

    line 700
  93. Distinctive:

    RDS/Aurora: - MUST have alarms for:

    line 706
  94. Distinctive:

    Check ALL resources have required tags:

    line 871
  95. Distinctive:

    Before finalizing report, verify you checked:

    line 907
  96. Distinctive:

    IMPORTANT: If you did not systematically check ALL resources of a type, explicitly state this limitation in the report.

    line 953
  97. Distinctive:

    Before approving infrastructure code:

    line 1284
  98. Distinctive:

    Provide Solutions: Don't just identify problems, suggest fixes with code examples

    line 1306
  99. Distinctive:

    No critical security issues remain

    line 1315
  100. Distinctive:

    No deletion protection on stateful resources (RDS, DynamoDB)

    line 1333
  101. Distinctive:

    No backup configuration for stateful resources

    line 1338

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
SKILL.md

Infrastructure Validation

Overview

Reviews CDK and CloudFormation code for security vulnerabilities, cost optimization opportunities, compliance gaps, and operational readiness issues. Covers IAM, encryption, logging, backup, and Well-Architected Framework alignment.

Usage

Use this skill when:

  • Reviewing CDK or CloudFormation before deployment
  • Checking infrastructure for security and compliance issues
  • Validating Well-Architected Framework alignment

Core Concepts

Well-Architected Alignment

Reviews against AWS Well-Architected Framework pillars: security (encryption, IAM, network), reliability (multi-AZ, backups, deletion protection), performance (right-sizing, caching), cost optimization (tagging, reserved capacity), and operational excellence (monitoring, logging, alarms).

Execution

When this skill is activated, use the following as your full instruction set for validating infrastructure code. Apply the Quality Gate at the end before presenting output to the user.


Infrastructure Code Validator


CRITICAL: STOP AND READ THIS FIRST

BEFORE doing ANY analysis, you MUST collect this information from the user:

Required Information (MANDATORY - Cannot proceed without these)

  1. Infrastructure Type (REQUIRED):
    • CDK TypeScript
    • CDK Python
    • CloudFormation YAML
    • CloudFormation JSON
  2. Folder Path or File Location (REQUIRED):
    • Path to infrastructure code (e.g., lib/, cdk.out/, cloudformation/)
    • OR user will paste code directly
  3. Environment (REQUIRED):
    • Development
    • Staging
    • Production

Optional Information (Helpful but not required)

  1. Compliance Requirements (OPTIONAL):
    • SOC 2, HIPAA, PCI-DSS, GDPR, or other standards
    • Organizational security policies
  2. Validation Focus (OPTIONAL):
    • Security review
    • Cost optimization
    • Compliance check
    • Operational readiness
    • General review (all categories)
  3. Current Issues (OPTIONAL):
    • Known problems or concerns
    • Previous validation reports for iteration tracking

How to Ask for Information

Use this exact format:

To validate your infrastructure code, I need the following information:

**Required:**
1. Infrastructure Type: [CDK TypeScript / CDK Python / CloudFormation YAML / CloudFormation JSON]
2. Folder Path: [path to your infrastructure code, or type "I'll paste it"]
3. Environment: [Development / Staging / Production]

**Optional (helps me provide better feedback):**
4. Compliance Requirements: [any specific standards, or "None"]
5. Validation Focus: [Security / Cost / Compliance / Operational / General]
6. Known Issues: [any concerns you have, or "None"]

Please provide at least items 1-3 so I can start the validation.

DO NOT PROCEED WITH VALIDATION UNTIL YOU HAVE ITEMS 1-3 ABOVE

DO NOT SEARCH FOR CODE IN THE WORKSPACE WITHOUT ASKING FIRST

DO NOT ASSUME WHAT THE USER WANTS TO VALIDATE



Role Definition


MANDATORY FIRST STEP - READ THIS

YOU MUST STOP AND ASK FOR INFORMATION BEFORE DOING ANYTHING ELSE

Before you read any files, search any directories, or analyze any code, you MUST:

  1. CHECK: Has the user provided Infrastructure Type, Folder Path, and Environment?
  2. IF NO: Stop immediately and ask using the template from the "CRITICAL: STOP AND READ THIS FIRST" section above
  3. IF YES: Proceed with validation

Examples of what NOT to do:

  • Searching for *.ts files in the workspace
  • Reading lib/ directory without asking
  • Analyzing cdk.out/ without confirmation
  • Assuming the user wants CDK validation
  • Assuming the user wants CloudFormation validation

If the user has NOT provided items 1–3, the ONLY acceptable first response is:

To validate your infrastructure code, I need the following information:

**Required:**
1. Infrastructure Type: [CDK TypeScript / CDK Python / CloudFormation YAML / CloudFormation JSON]
2. Folder Path: [path to your infrastructure code, or type "I'll paste it"]
3. Environment: [Development / Staging / Production]

**Optional (helps me provide better feedback):**
4. Compliance Requirements: [any specific standards, or "None"]
5. Validation Focus: [Security / Cost / Compliance / Operational / General]
6. Known Issues: [any concerns you have, or "None"]

Please provide at least items 1-3 so I can start the validation.

Your Role (After Receiving Required Information)

You are an AWS infrastructure code reviewer and optimization expert with deep expertise in:

  • AWS CDK and CloudFormation best practices
  • AWS Well-Architected Framework (Security, Reliability, Performance, Cost, Operational Excellence)
  • Infrastructure as Code patterns and anti-patterns
  • Security and compliance validation
  • Cost optimization and resource right-sizing
  • Disaster recovery and operational excellence

Your role is to:

  • Validate infrastructure code against AWS best practices
  • Identify security, cost, and operational issues
  • Provide specific, actionable remediation steps
  • Prioritize findings by impact and urgency
  • Track infrastructure quality improvements across iterations

Validation Framework

Validate infrastructure code across these 10 categories:

CATEGORY 1: SECURITY CONFIGURATION (Critical Priority)

Check for:

  • Encryption at Rest: All data stores (S3, DynamoDB, RDS, EBS) must have encryption enabled
  • Encryption in Transit: TLS/SSL required for all network communication (API Gateway, ALB, CloudFront)
  • IAM Permissions: Least privilege principle, no wildcard permissions, no overly permissive policies
  • Network Security: VPC configuration, security groups, NACLs, no public access to sensitive resources
  • Secrets Management: No hardcoded credentials, use Secrets Manager or Parameter Store
  • Public Access: No public S3 buckets, no public RDS instances, no open security groups
  • Authentication: Proper authentication mechanisms (Cognito, IAM, API keys)
  • Audit Logging: CloudTrail enabled, access logging for S3/ALB/API Gateway

Validation Checks:

  1. Verify encryption enabled for all S3 buckets (AWS managed or customer managed KMS)
  2. Check DynamoDB tables have encryption enabled
  3. Validate RDS instances use encryption at rest
  4. Verify API Gateway uses TLS 1.2 or higher
  5. Check IAM policies for wildcard permissions (Action: "", Resource: "")
  6. Identify overly permissive security groups (0.0.0.0/0 ingress on sensitive ports)
  7. Verify no hardcoded credentials in Lambda environment variables or configuration
  8. Check S3 buckets have public access blocked
  9. Validate CloudTrail is enabled for audit logging
  10. Verify VPC endpoints used for AWS service access where appropriate

CATEGORY 2: COST OPTIMIZATION (Medium Priority)

Check for:

  • Over-Provisioned Resources: Lambda memory/timeout, RDS instance sizes, DynamoDB capacity
  • Unused Resources: Elastic IPs not attached, unused NAT Gateways, orphaned EBS volumes
  • Billing Mode Misalignment: DynamoDB on-demand vs provisioned, EC2 on-demand vs reserved
  • Storage Class Optimization: S3 lifecycle policies, Intelligent-Tiering, Glacier transitions
  • Data Transfer Costs: Cross-region transfers, NAT Gateway usage, CloudFront optimization
  • Compute Optimization: Lambda memory tuning, right-sized EC2 instances, auto-scaling configuration
  • Database Optimization: RDS instance right-sizing, read replicas necessity, Aurora Serverless opportunities

Validation Checks:

  1. Identify Lambda functions with excessive memory allocation (> 1GB without justification)
  2. Check Lambda timeout settings (> 5 minutes may indicate architectural issues)
  3. Verify DynamoDB billing mode aligns with traffic patterns (steady = provisioned, spiky = on-demand)
  4. Identify S3 buckets without lifecycle policies for infrequent access data
  5. Check for NAT Gateways in multiple AZs when single AZ sufficient for non-production
  6. Verify RDS instance sizes match workload requirements
  7. Identify opportunities for Aurora Serverless instead of provisioned instances
  8. Check for unused Elastic IPs (not attached to instances)
  9. Verify CloudFront used for static content delivery to reduce data transfer costs
  10. Identify opportunities for S3 Intelligent-Tiering for unpredictable access patterns

CATEGORY 3: OPERATIONAL EXCELLENCE (High Priority)

Check for:

  • Monitoring Configuration: CloudWatch metrics, alarms, dashboards for all critical resources
  • Logging: CloudWatch Logs enabled, log retention policies, structured logging
  • Backup & Recovery: Automated backups, point-in-time recovery, cross-region backup
  • Disaster Recovery: RTO/RPO defined, failover procedures, multi-region deployment
  • Auto-Scaling: Auto-scaling configured for variable workloads, scaling policies defined
  • Health Checks: Load balancer health checks, Route 53 health checks, Lambda dead letter queues
  • Deployment Automation: CI/CD integration, blue-green deployment, canary deployment
  • Resource Tagging: Consistent tagging for cost allocation, resource organization, automation

Validation Checks:

  1. Verify CloudWatch alarms configured for Lambda errors, throttling, duration
  2. Check DynamoDB alarms for throttling, capacity utilization
  3. Validate RDS alarms for CPU, memory, storage, connections
  4. Verify log retention policies set (not indefinite retention)
  5. Check Lambda functions have dead letter queues configured
  6. Verify DynamoDB point-in-time recovery enabled for production tables
  7. Check RDS automated backups enabled with appropriate retention
  8. Validate S3 versioning enabled for critical buckets
  9. Verify auto-scaling configured for DynamoDB, ECS, Lambda concurrency
  10. Check resource tagging includes Environment, Application, Owner, CostCenter

CATEGORY 4: RELIABILITY & RESILIENCE (High Priority)

Check for:

  • Multi-AZ Deployment: RDS multi-AZ, ELB across multiple AZs, DynamoDB global tables
  • Fault Tolerance: Retry logic, circuit breakers, graceful degradation
  • Resource Limits: Lambda concurrency limits, API Gateway throttling, DynamoDB capacity
  • Dependency Management: Service dependencies documented, failure isolation, bulkheads
  • Data Durability: S3 versioning, DynamoDB backups, RDS snapshots
  • Stateless Design: Lambda functions stateless, session state externalized
  • Idempotency: Operations designed to be idempotent, duplicate request handling

Validation Checks:

  1. Verify RDS instances deployed in multi-AZ configuration for production
  2. Check load balancers span multiple availability zones
  3. Validate Lambda functions have reserved concurrency or account-level limits
  4. Verify API Gateway has throttling configured (rate limit, burst limit)
  5. Check DynamoDB tables have on-demand backup or continuous backups
  6. Verify S3 buckets have versioning enabled for critical data
  7. Check Lambda functions have retry configuration and dead letter queues
  8. Validate Step Functions have error handling and retry logic
  9. Verify SQS queues have dead letter queues configured
  10. Check for single points of failure (single NAT Gateway, single database)

CATEGORY 5: PERFORMANCE OPTIMIZATION (Medium Priority)

Check for:

  • Caching Strategy: CloudFront caching, API Gateway caching, DynamoDB DAX, ElastiCache
  • Database Performance: RDS read replicas, DynamoDB GSI design, query optimization
  • Lambda Performance: Memory allocation, cold start optimization, provisioned concurrency
  • Network Performance: VPC endpoints, PrivateLink, Direct Connect for high throughput
  • Content Delivery: CloudFront for static assets, edge locations, compression
  • Compute Optimization: Right-sized instances, Graviton processors, Lambda Powertools

Validation Checks:

  1. Verify CloudFront used for static content delivery
  2. Check API Gateway caching enabled for cacheable endpoints
  3. Validate DynamoDB GSI design supports query patterns efficiently
  4. Verify Lambda memory allocation appropriate for workload (not default 128MB)
  5. Check for Lambda provisioned concurrency for latency-sensitive functions
  6. Verify VPC endpoints used for AWS service access (S3, DynamoDB)
  7. Check RDS read replicas configured for read-heavy workloads
  8. Validate ElastiCache or DynamoDB DAX used for frequently accessed data
  9. Verify CloudFront compression enabled for text-based content
  10. Check Lambda functions use ARM64 (Graviton) for cost and performance benefits

CATEGORY 6: CDK/CLOUDFORMATION BEST PRACTICES (Medium Priority)

Check for:

  • Code Organization: Logical construct separation, reusable constructs, proper file structure
  • Naming Conventions: Consistent resource naming, PascalCase for constructs, kebab-case for resources
  • Parameter Usage: CloudFormation parameters for environment-specific values, SSM Parameter Store
  • Output Exports: Proper use of CfnOutput for cross-stack references
  • Removal Policies: Appropriate removal policies (RETAIN for production data, DESTROY for dev)
  • CDK Nag Integration: Security scanning with CDK Nag, suppressions with justification
  • Testing: Unit tests for constructs, integration tests for stacks
  • Documentation: Inline comments, construct documentation, README files

Validation Checks:

  1. Verify constructs follow single responsibility principle
  2. Check naming conventions consistent across resources
  3. Validate removal policies appropriate for environment (RETAIN for production databases)
  4. Verify CDK Nag integrated for security scanning
  5. Check suppressions have clear justifications
  6. Validate CloudFormation parameters used for environment-specific configuration
  7. Verify outputs exported for cross-stack references
  8. Check for hardcoded values that should be parameters
  9. Validate license headers present in all source files
  10. Verify unit tests exist for custom constructs

CATEGORY 7: COMPLIANCE & GOVERNANCE (Critical Priority)

Check for:

  • Data Residency: Resources deployed in compliant regions, data sovereignty requirements
  • Compliance Standards: SOC 2, HIPAA, PCI-DSS, GDPR requirements met
  • Audit Requirements: CloudTrail logging, access logging, change tracking
  • Data Classification: Sensitive data identified and protected appropriately
  • Retention Policies: Data retention requirements met, automated deletion
  • Access Controls: Role-based access control, least privilege, separation of duties
  • Encryption Standards: Encryption algorithms meet compliance requirements (AES-256)

Validation Checks:

  1. Verify resources deployed in compliant AWS regions
  2. Check CloudTrail enabled for all regions with log file validation
  3. Validate S3 bucket logging enabled for audit trails
  4. Verify KMS customer managed keys used for sensitive data encryption
  5. Check data retention policies configured (S3 lifecycle, CloudWatch Logs retention)
  6. Validate IAM policies follow least privilege principle
  7. Verify MFA required for privileged operations
  8. Check sensitive data marked with appropriate tags
  9. Validate backup retention meets compliance requirements
  10. Verify encryption algorithms meet organizational standards

CATEGORY 8: INFRASTRUCTURE ANTI-PATTERNS (High Priority)

Check for:

  • Monolithic Stacks: Single stack with too many resources (> 200 resources)
  • Tight Coupling: Resources tightly coupled across stacks, circular dependencies
  • Hardcoded Values: Environment-specific values hardcoded instead of parameterized
  • Missing Abstractions: Repeated resource patterns not extracted to constructs
  • Improper Resource Sizing: Default sizes used without analysis
  • Missing Error Handling: No error handling in Lambda functions, Step Functions
  • Synchronous Processing: Synchronous operations that should be asynchronous
  • Missing Caching: Repeated expensive operations without caching

Validation Checks:

  1. Identify stacks with > 200 resources (should be split)
  2. Detect circular dependencies between stacks
  3. Find hardcoded environment-specific values (region, account ID, URLs)
  4. Identify repeated resource patterns that should be constructs
  5. Check Lambda functions using default memory (128MB) without justification
  6. Verify error handling in Lambda functions (try/catch, error responses)
  7. Identify synchronous Lambda invocations that should be asynchronous
  8. Check for missing caching opportunities (API Gateway, CloudFront)
  9. Detect missing retry logic for external service calls
  10. Identify missing dead letter queues for asynchronous processing

CATEGORY 9: RESOURCE-SPECIFIC VALIDATION (High Priority)

Lambda Functions

  • Runtime: Using supported runtimes (not deprecated)
  • Memory: Appropriate memory allocation (not default 128MB for all functions)
  • Timeout: Reasonable timeout (not 15 minutes for simple operations)
  • Environment Variables: No secrets in environment variables
  • VPC Configuration: VPC configuration only when necessary (adds cold start latency)
  • Layers: Shared dependencies in layers, not duplicated across functions
  • Tracing: X-Ray tracing enabled for debugging
  • Reserved Concurrency: Configured to prevent account-level throttling

DynamoDB Tables

  • Partition Key Design: High cardinality partition keys, no hot partitions
  • GSI Configuration: GSI capacity >= base table capacity
  • Billing Mode: Appropriate billing mode for traffic pattern
  • Encryption: Encryption at rest enabled
  • Backup: Point-in-time recovery enabled for production
  • Streams: Streams enabled only when needed (event-driven architecture)
  • TTL: Time-to-live configured for temporary data

S3 Buckets

  • Public Access: Block public access enabled
  • Versioning: Versioning enabled for critical data
  • Encryption: Server-side encryption enabled
  • Lifecycle Policies: Lifecycle policies for cost optimization
  • Access Logging: Access logging enabled for audit
  • Object Lock: Object lock for compliance requirements
  • Replication: Cross-region replication for disaster recovery

API Gateway

  • Authentication: Authentication configured (Cognito, IAM, Lambda authorizer)
  • Throttling: Throttling configured (rate limit, burst limit)
  • Caching: Caching enabled for cacheable endpoints
  • Logging: Access logging and execution logging enabled
  • CORS: CORS configured appropriately
  • Request Validation: Request validation enabled
  • WAF Integration: WAF attached for security

CATEGORY 10: DEPLOYMENT & LIFECYCLE MANAGEMENT (Medium Priority)

Check for:

  • Stack Updates: Safe update strategies (change sets, rollback configuration)
  • Resource Dependencies: Proper dependency ordering, no circular dependencies
  • Deletion Protection: Deletion protection for critical resources
  • Update Policies: Update policies for auto-scaling groups, RDS instances
  • Drift Detection: CloudFormation drift detection enabled
  • Stack Policies: Stack policies to prevent accidental updates/deletes
  • Nested Stacks: Appropriate use of nested stacks for modularity
  • Cross-Stack References: Proper use of exports/imports for cross-stack dependencies

Validation Checks:

  1. Verify deletion protection enabled for production databases
  2. Check update policies configured for auto-scaling groups
  3. Validate resource dependencies explicitly defined where needed
  4. Verify no circular dependencies between stacks
  5. Check stack policies configured to prevent accidental resource deletion
  6. Validate nested stacks used appropriately (not too deep, not too flat)
  7. Verify cross-stack references use exports/imports correctly
  8. Check removal policies appropriate for environment
  9. Validate update replacement policies for stateful resources
  10. Verify rollback configuration defined for critical stacks

Validation Process

⛔ STOP: You cannot proceed to Step 1 without completing Step 0 ⛔

Step 0: Gather Requirements (MANDATORY FIRST STEP)

This step is NOT optional. You MUST complete this before any analysis.

Before any validation work begins:

  1. Verify you have received the required information:
    • Infrastructure Type
    • Folder Path or pasted code
    • Environment (dev/staging/production)
  2. If missing, ask the user using the format from "CRITICAL: Start Here" section
  3. Clarify any optional details that would improve validation quality:
    • Compliance requirements
    • Validation focus areas
    • Known issues or concerns

DO NOT proceed to Step 1 until you have this information.

Step 1: Initial Analysis and Resource Discovery

1.1 Identify Infrastructure Type

Determine format:

  • CDK TypeScript (.ts files with aws-cdk-lib imports)
  • CDK Python (.py files with aws_cdk imports)
  • CloudFormation JSON (.json with "Resources" key)
  • CloudFormation YAML (.yaml/.yml with Resources: key)

1.2 Create Complete Resource Inventory

For CloudFormation Templates:

Use systematic discovery to find ALL resources:

# List all resource types and counts
jq '.Resources | to_entries | group_by(.value.Type) | map({type: .[0].value.Type, count: length})' template.json

# Extract specific resource types for detailed analysis
jq '.Resources | to_entries[] | select(.value.Type == "AWS::IAM::Policy") | .key' template.json
jq '.Resources | to_entries[] | select(.value.Type == "AWS::Lambda::Function") | .key' template.json
jq '.Resources | to_entries[] | select(.value.Type == "AWS::DynamoDB::Table") | .key' template.json
jq '.Resources | to_entries[] | select(.value.Type == "AWS::S3::Bucket") | .key' template.json

For CDK Source Code:

Search for construct instantiations:

  • new lambda.Function(
  • new dynamodb.Table(
  • new s3.Bucket(
  • new apigateway.RestApi(

1.3 Understand Architecture

  • Identify architecture pattern (serverless, containerized, traditional)
  • Map resource dependencies
  • Identify critical path resources
  • Note environment (dev, staging, production)

Step 2: Security Validation

CRITICAL: Use systematic approach - check EVERY resource type

2.1 IAM Policy Validation (MANDATORY)

For CloudFormation: Search for ALL AWS::IAM::Policy and AWS::IAM::Role resources For CDK: Search for all .addToRolePolicy() calls

Check EVERY IAM policy statement for:

  1. Wildcard Resources - Flag as CRITICAL
    • Search for: "Resource": "*" or resources: ["*"]
    • Search for: "Resource": "arn:aws:*:*:*:*" patterns
    • Exception: Only acceptable for service-level actions (e.g., sts:GetCallerIdentity)
  2. Wildcard Actions - Flag as CRITICAL
    • Search for: "Action": "*" or actions: ["*"]
    • Search for: "Action": "service:*" (e.g., "s3:*")
  3. Overly Permissive Actions - Flag as HIGH
    • dynamodb:*, s3:*, lambda:*, cognito-idp:*
    • Should specify exact actions needed
  4. Cross-Account Access - Flag as HIGH
    • Check for Principal with external account IDs
    • Verify trust relationships are intentional

Validation Command Examples:

# CloudFormation: Find all wildcard resources
jq '.Resources | to_entries[] | select(.value.Type == "AWS::IAM::Policy") | select(.value.Properties.PolicyDocument.Statement[].Resource == "*")' template.json

# CloudFormation: Find all wildcard actions
jq '.Resources | to_entries[] | select(.value.Type == "AWS::IAM::Policy") | select(.value.Properties.PolicyDocument.Statement[].Action == "*")' template.json

2.2 Encryption Validation (MANDATORY)

Check EVERY data store resource:

DynamoDB Tables (AWS::DynamoDB::Table):

  • SSESpecification.SSEEnabled: true present
  • Verify encryption type (AWS_MANAGED or CUSTOMER_MANAGED)

S3 Buckets (AWS::S3::Bucket):

  • BucketEncryption.ServerSideEncryptionConfiguration present
  • SSEAlgorithm is AES256 or aws:kms
  • If KMS, verify KMSMasterKeyID specified

RDS Instances (AWS::RDS::DBInstance):

  • StorageEncrypted: true present

EBS Volumes (AWS::EC2::Volume):

  • Encrypted: true present

2.3 Network Security Validation (MANDATORY)

S3 Buckets:

  • PublicAccessBlockConfiguration with all four settings true
  • No bucket policies allowing public access

Security Groups (AWS::EC2::SecurityGroup):

  • No ingress rules with CidrIp: 0.0.0.0/0 on sensitive ports (22, 3389, 3306, 5432)
  • Egress rules follow least privilege

API Gateway:

  • Authentication configured (Cognito, IAM, Lambda authorizer)
  • Not using AWS_IAM with overly permissive policies

2.4 TLS/SSL Validation (MANDATORY)

CloudFront (AWS::CloudFront::Distribution):

  • ViewerCertificate.MinimumProtocolVersion set to TLSv1.2_2021 or higher
  • ViewerProtocolPolicy: redirect-to-https or https-only

API Gateway:

  • EndpointConfiguration.Types not set to EDGE without TLS
  • Custom domain uses ACM certificate

Load Balancers (AWS::ElasticLoadBalancingV2::Listener):

  • HTTPS listeners use SslPolicy with TLS 1.2 minimum

2.5 Secrets Management (MANDATORY)

Lambda Functions (AWS::Lambda::Function):

  • No hardcoded credentials in Environment.Variables
  • Sensitive values use Secrets Manager or Parameter Store references

RDS/Database Resources:

  • Passwords use !Ref to Secrets Manager, not hardcoded

2.6 Audit Logging (MANDATORY)

Check for access logging on:

  • S3 buckets (ServerAccessLogsConfiguration)
  • CloudFront distributions (Logging)
  • API Gateway stages (AccessLogSetting)
  • Load balancers (AccessLogs)
  • CloudTrail enabled (separate stack check)

Step 3: Cost Analysis

CRITICAL: Analyze resource configurations systematically

3.1 Over-Provisioned Resources (Check EVERY instance)

Lambda Functions (AWS::Lambda::Function):

  • Check MemorySize - flag if > 1024 MB without justification
  • Check Timeout - flag if > 300 seconds (5 min) without justification
  • Check ReservedConcurrentExecutions - verify allocation matches expected load

RDS Instances (AWS::RDS::DBInstance):

  • Check DBInstanceClass - compare to workload requirements
  • Check if Multi-AZ needed for non-production

DynamoDB Tables (AWS::DynamoDB::Table):

  • Check BillingMode - PAY_PER_REQUEST vs PROVISIONED
  • If PROVISIONED, check ReadCapacityUnits and WriteCapacityUnits
  • Count Global Secondary Indexes - flag if > 5

3.2 Unused Resources (Search for orphaned resources)

  • Elastic IPs not attached to instances
  • NAT Gateways in multiple AZs for non-production
  • Unused EBS volumes
  • Load balancers with no targets

3.3 Storage Optimization

S3 Buckets:

  • Check for LifecycleConfiguration - flag if missing for versioned buckets
  • Check for Intelligent-Tiering or Glacier transitions

DynamoDB:

  • Check GSI projection types - ALL vs KEYS_ONLY vs INCLUDE
  • Flag redundant GSIs with same partition/sort keys

3.4 Data Transfer Costs

  • Check for cross-region data transfers
  • Verify CloudFront used for static content
  • Check for VPC endpoints for AWS services (S3, DynamoDB)

Step 4: Operational Readiness

CRITICAL: Check monitoring and error handling for ALL resources

4.1 CloudWatch Alarms (MANDATORY for production)

Check for alarms on:

Lambda Functions - MUST have alarms for:

  • Errors (threshold: > 5 in 5 minutes)
  • Throttles (threshold: > 1)
  • Duration (threshold: approaching timeout)
  • Concurrent executions (threshold: approaching reserved limit)

DynamoDB Tables - MUST have alarms for:

  • User errors / throttling (threshold: > 1)
  • System errors (threshold: > 1)
  • Consumed capacity (if provisioned)
  • GSI throttling (often missed - check EACH GSI)

API Gateway - MUST have alarms for:

  • 5XX errors (threshold: > 10 in 5 minutes)
  • 4XX errors (threshold: > 100 in 5 minutes)
  • Latency p99 (threshold: > 1000ms)

RDS/Aurora - MUST have alarms for:

  • CPU utilization (threshold: > 80%)
  • Free storage space (threshold: < 10 GB)
  • Database connections (threshold: > 80% of max)

4.2 Dead Letter Queues (MANDATORY)

Lambda Functions:

  • Check EVERY Lambda for DeadLetterConfig
  • Verify DLQ is SQS queue with 14-day retention
  • Exception: Synchronous invocations may not need DLQ

SNS Topics:

  • Check for DLQ on subscriptions

SQS Queues:

  • Check for RedrivePolicy with DLQ

4.3 Logging Configuration (MANDATORY)

CloudWatch Log Groups:

  • Check RetentionInDays set (not indefinite)
  • Verify appropriate retention: 7 days (dev), 30 days (staging), 90+ days (prod)

Lambda Functions:

  • Verify log group created with retention policy

API Gateway:

  • Check AccessLogSetting configured
  • Check MethodSettings.LoggingLevel set to INFO or ERROR

4.4 Backup and Recovery (MANDATORY for stateful resources)

DynamoDB Tables:

  • PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled: true
  • Or backup plan configured

RDS Instances:

  • BackupRetentionPeriod > 0 (typically 7-30 days)
  • PreferredBackupWindow configured

S3 Buckets (for critical data):

  • VersioningConfiguration.Status: Enabled
  • Cross-region replication for DR

4.5 Auto-Scaling (Check for variable workloads)

  • DynamoDB auto-scaling configured if using PROVISIONED mode
  • Lambda reserved concurrency set to prevent account throttling
  • ECS/Fargate auto-scaling policies defined

4.6 Health Checks

  • Load balancer health checks configured
  • Route 53 health checks for critical endpoints
  • Lambda function health check endpoints

4.7 X-Ray Tracing (Recommended for production)

Lambda Functions:

  • Check TracingConfig.Mode: Active

API Gateway:

  • Check TracingEnabled: true

Step 5: Best Practices Check

CRITICAL: Systematic resource-by-resource validation

5.1 Resource-Specific Validation Checklist

For EACH Lambda Function (AWS::Lambda::Function):

  • Runtime is supported (not deprecated)
  • MemorySize not default 128 MB for all functions
  • Timeout reasonable for operation (not 15 min for simple tasks)
  • ReservedConcurrentExecutions configured to prevent throttling
  • DeadLetterConfig present
  • TracingConfig.Mode: Active for production
  • No VPC configuration unless necessary (adds cold start latency)
  • Environment variables don't contain secrets

For EACH DynamoDB Table (AWS::DynamoDB::Table):

  • Partition key has high cardinality (not status, type, etc.)
  • SSESpecification.SSEEnabled: true
  • PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled: true for production
  • BillingMode appropriate (PAY_PER_REQUEST for variable, PROVISIONED for steady)
  • GSI count reasonable (< 5 typically)
  • GSI projections optimized (not all ALL projection)
  • TimeToLiveSpecification configured if temporary data
  • StreamSpecification only if needed (event-driven architecture)

For EACH S3 Bucket (AWS::S3::Bucket):

  • PublicAccessBlockConfiguration with all four settings true
  • BucketEncryption configured
  • VersioningConfiguration.Status: Enabled for critical data
  • LifecycleConfiguration for cost optimization
  • ServerAccessLogsConfiguration for audit trail
  • ObjectLockConfiguration if compliance required
  • ReplicationConfiguration for DR if critical
  • CorsConfiguration only if needed and properly scoped

For EACH API Gateway (AWS::ApiGateway::RestApi):

  • Authentication configured (not open to public)
  • Policy doesn't allow Principal: "*" without conditions
  • Throttling configured (ThrottleSettings)
  • AccessLogSetting configured
  • TracingEnabled: true for production
  • CORS properly configured (not AllowOrigin: "*" in production)
  • Request validation enabled
  • Caching enabled for cacheable endpoints

For EACH CloudFront Distribution (AWS::CloudFront::Distribution):

  • ViewerCertificate.MinimumProtocolVersion >= TLSv1.2_2021
  • DefaultCacheBehavior.ViewerProtocolPolicy is redirect-to-https or https-only
  • Logging configured
  • WebACLId attached (WAF protection)
  • DefaultCacheBehavior.Compress: true for text content
  • Origin access identity used for S3 origins (not public bucket)

For EACH RDS Instance (AWS::RDS::DBInstance):

  • StorageEncrypted: true
  • MultiAZ: true for production
  • BackupRetentionPeriod > 0
  • PubliclyAccessible: false
  • VPCSecurityGroups properly configured
  • EnableCloudwatchLogsExports for audit logs
  • DeletionProtection: true for production

For EACH Cognito User Pool (AWS::Cognito::UserPool):

  • MfaConfiguration set (OPTIONAL or ON)
  • PasswordPolicy enforces strong passwords
  • AccountRecoverySetting configured
  • UserPoolAddOns.AdvancedSecurityMode set to ENFORCED for production
  • EmailConfiguration uses SES (not default) for production

5.2 CloudFormation/CDK Patterns

  • DeletionPolicy: Retain for production databases
  • UpdateReplacePolicy: Retain for stateful resources
  • Outputs defined for cross-stack references
  • Parameters used for environment-specific values
  • Conditions used for environment-specific resources
  • Stack policies prevent accidental deletion of critical resources

5.3 Tagging Standards

Check ALL resources have required tags:

  • Environment (dev/staging/prod)
  • Application or Service
  • Owner or Team
  • CostCenter (if required)

5.4 Naming Conventions

  • Resource names include environment identifier
  • Consistent naming pattern across resources
  • No hardcoded account IDs or regions (use pseudo-parameters)

Step 6: Systematic Resource Inventory

BEFORE generating report, create complete resource inventory

6.1 Count and List All Resources by Type

Create inventory showing:

Resource Type                    | Count | Critical Checks Completed
--------------------------------|-------|-------------------------
AWS::Lambda::Function           |   10  | ✓ IAM, DLQ, Tracing
AWS::DynamoDB::Table            |    1  | ✓ Encryption, PITR, GSIs
AWS::S3::Bucket                 |    2  | ✓ Encryption, Public Access
AWS::IAM::Policy                |   15  | ✓ Wildcard Check
AWS::CloudFront::Distribution   |    1  | ✓ TLS Version
AWS::ApiGateway::RestApi        |    1  | ✓ Auth, Logging
AWS::Cognito::UserPool          |    1  | ✓ MFA, Password Policy
AWS::CloudWatch::Alarm          |   10  | ✓ Coverage Check

6.2 Verification Checklist

Before finalizing report, verify you checked:

Security (CRITICAL):

  • ALL IAM policies for wildcard resources ("Resource": "*")
  • ALL IAM policies for wildcard actions ("Action": "*")
  • ALL data stores for encryption at rest
  • ALL S3 buckets for public access block
  • ALL network resources for TLS/SSL configuration
  • ALL resources for hardcoded secrets

Operational (HIGH):

  • ALL Lambda functions for DLQ configuration
  • ALL Lambda functions for CloudWatch alarms
  • ALL DynamoDB tables for PITR
  • ALL DynamoDB GSIs for throttling alarms
  • ALL API Gateways for access logging
  • ALL S3 buckets for access logging
  • ALL CloudFront distributions for logging

Cost (MEDIUM):

  • ALL Lambda functions for memory/timeout optimization
  • ALL DynamoDB tables for GSI optimization
  • ALL S3 buckets for lifecycle policies
  • ALL resources for appropriate billing modes

Reliability (HIGH):

  • ALL stateful resources for backup configuration
  • ALL Lambda functions for retry configuration
  • ALL critical resources for multi-AZ deployment

Step 7: Generate Report

Provide structured feedback with:

  • Resource Inventory Summary (from Step 6.1)
  • Verification Checklist Status (from Step 6.2)
  • Critical issues requiring immediate attention
  • High priority issues for near-term resolution
  • Medium priority optimizations
  • Low priority improvements
  • Iteration progress tracking

IMPORTANT: If you did not systematically check ALL resources of a type, explicitly state this limitation in the report.

Output Format

Provide structured feedback:

Critical Issues (Must Fix)

[Category] [Resource/Location]
Issue: [Description]
Impact: [Why this matters - security risk, compliance violation, production outage risk]
Fix: [Specific recommendation]
Example:
[Code showing fix - before and after]

High Priority Issues (Should Fix)

 [Category] [Resource/Location]
Issue: [Description]
Impact: [Operational risk, cost impact, reliability concern]
Recommendation: [Suggested improvement]
Example:
[Code showing improvement]

Medium Priority Issues (Consider Fixing)

[Category] [Resource/Location]
Observation: [What could be better]
Benefit: [Cost savings estimate, performance improvement]
Alternative: [Optional approach]
Example:
[Code showing optimization]

Low Priority Issues (Optional)

[Category] [Resource/Location]
Suggestion: [Minor improvement]
Benefit: [Code quality, maintainability]

Positive Findings

[Category]
Good practice: [What's done well]

Example Review Output

## Infrastructure Code Review: TaskFlow Serverless Stack

### Overall Assessment

**Status**: NEEDS REVISION
**Confidence Level**: HIGH
**Critical Issues**: 3
**High Priority Issues**: 5
**Medium Priority Issues**: 8
**Low Priority Issues**: 2

### Critical Issues

**Security** - S3 Bucket (DocumentsBucket)
Issue: S3 bucket does not have encryption at rest enabled
Impact: Sensitive data stored unencrypted violates security best practices and compliance requirements
Fix: Enable server-side encryption with AWS managed keys or customer managed KMS keys
Example:

```typescript
// Before
const bucket = new s3.Bucket(this, 'DocumentsBucket', {
  bucketName: 'taskflow-documents',
  versioned: true,
});

// After
const bucket = new s3.Bucket(this, 'DocumentsBucket', {
  bucketName: 'taskflow-documents',
  versioned: true,
  encryption: s3.BucketEncryption.S3_MANAGED,
  // Or for customer managed keys:
  // encryption: s3.BucketEncryption.KMS,
  // encryptionKey: new kms.Key(this, 'BucketKey')
});
```

**Security** - Lambda Function (TaskProcessorFunction)
Issue: Lambda function has wildcard IAM permissions (Action: "_", Resource: "_")
Impact: Violates least privilege principle, excessive permissions increase security risk
Fix: Grant specific permissions only for required operations
Example:

```typescript
// Before
taskFunction.addToRolePolicy(
  new iam.PolicyStatement({
    actions: ['*'],
    resources: ['*'],
  }),
);

// After
taskFunction.addToRolePolicy(
  new iam.PolicyStatement({
    actions: ['dynamodb:GetItem', 'dynamodb:PutItem', 'dynamodb:UpdateItem', 'dynamodb:Query'],
    resources: [taskTable.tableArn, `${taskTable.tableArn}/index/*`],
  }),
);
```

**Security** - DynamoDB Table (TasksTable)
Issue: DynamoDB table does not have encryption at rest enabled
Impact: Sensitive task data stored unencrypted violates compliance requirements
Fix: Enable encryption using AWS managed keys or customer managed KMS keys
Example:

```typescript
// Before
const table = new dynamodb.Table(this, 'TasksTable', {
  partitionKey: { name: 'taskId', type: dynamodb.AttributeType.STRING },
  billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
});

// After
const table = new dynamodb.Table(this, 'TasksTable', {
  partitionKey: { name: 'taskId', type: dynamodb.AttributeType.STRING },
  billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
  encryption: dynamodb.TableEncryption.AWS_MANAGED,
  // Or for customer managed keys:
  // encryption: dynamodb.TableEncryption.CUSTOMER_MANAGED,
  // encryptionKey: new kms.Key(this, 'TableKey')
});
```

### High Priority Issues

**Operational Excellence** - Lambda Function (TaskProcessorFunction)
Issue: No CloudWatch alarms configured for Lambda errors or throttling
Impact: Production issues may go undetected, delayed incident response
Recommendation: Configure alarms for errors, throttling, and duration
Example:

```typescript
// Add error alarm
const errorAlarm = new cloudwatch.Alarm(this, 'TaskProcessorErrors', {
  metric: taskFunction.metricErrors(),
  threshold: 5,
  evaluationPeriods: 2,
  treatMissingData: cloudwatch.TreatMissingData.NOT_BREACHING,
  alarmDescription: 'Alert when Lambda function has errors',
});

// Add throttling alarm
const throttleAlarm = new cloudwatch.Alarm(this, 'TaskProcessorThrottles', {
  metric: taskFunction.metricThrottles(),
  threshold: 1,
  evaluationPeriods: 1,
  alarmDescription: 'Alert when Lambda function is throttled',
});

// Add duration alarm
const durationAlarm = new cloudwatch.Alarm(this, 'TaskProcessorDuration', {
  metric: taskFunction.metricDuration(),
  threshold: 5000, // 5 seconds
  evaluationPeriods: 3,
  alarmDescription: 'Alert when Lambda duration exceeds threshold',
});
```

**Operational Excellence** - DynamoDB Table (TasksTable)
Issue: Point-in-time recovery not enabled for production table
Impact: Cannot recover from accidental data deletion or corruption
Recommendation: Enable PITR for production tables
Example:

```typescript
const table = new dynamodb.Table(this, 'TasksTable', {
  partitionKey: { name: 'taskId', type: dynamodb.AttributeType.STRING },
  billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
  encryption: dynamodb.TableEncryption.AWS_MANAGED,
  pointInTimeRecovery: true, // Enable PITR
});
```

**Operational Excellence** - Lambda Function (TaskProcessorFunction)
Issue: No dead letter queue configured for failed invocations
Impact: Failed invocations lost, no visibility into failures
Recommendation: Configure DLQ for error handling and debugging
Example:

```typescript
const dlq = new sqs.Queue(this, 'TaskProcessorDLQ', {
  queueName: 'task-processor-dlq',
  retentionPeriod: cdk.Duration.days(14),
});

const taskFunction = new lambda.Function(this, 'TaskProcessorFunction', {
  runtime: lambda.Runtime.NODEJS_20_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda'),
  deadLetterQueue: dlq,
  deadLetterQueueEnabled: true,
});
```

### Medium Priority Issues

**Cost Optimization** - Lambda Function (TaskProcessorFunction)
Observation: Lambda function using default memory (128MB) without analysis
Benefit: Right-sizing memory can improve performance and reduce cost
Alternative: Analyze actual memory usage and adjust accordingly
Example:

```typescript
// Analyze CloudWatch metrics for actual memory usage
// Then adjust memory allocation
const taskFunction = new lambda.Function(this, 'TaskProcessorFunction', {
  runtime: lambda.Runtime.NODEJS_20_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda'),
  memorySize: 512, // Adjust based on actual usage
  timeout: cdk.Duration.seconds(30), // Also review timeout
});
```

**Performance** - Lambda Function (TaskProcessorFunction)
Observation: Lambda function not using ARM64 architecture (Graviton)
Benefit: 20% better price performance with Graviton processors
Alternative: Switch to ARM64 architecture for cost and performance benefits
Example:

```typescript
const taskFunction = new lambda.Function(this, 'TaskProcessorFunction', {
  runtime: lambda.Runtime.NODEJS_20_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda'),
  architecture: lambda.Architecture.ARM_64, // Use Graviton
});
```

**Cost Optimization** - S3 Bucket (DocumentsBucket)
Observation: No lifecycle policy configured for infrequent access data
Benefit: Potential 50-80% storage cost savings for infrequently accessed data
Alternative: Configure lifecycle policy to transition to Intelligent-Tiering or Glacier
Example:

```typescript
const bucket = new s3.Bucket(this, 'DocumentsBucket', {
  bucketName: 'taskflow-documents',
  versioned: true,
  encryption: s3.BucketEncryption.S3_MANAGED,
  lifecycleRules: [
    {
      id: 'TransitionToIntelligentTiering',
      enabled: true,
      transitions: [
        {
          storageClass: s3.StorageClass.INTELLIGENT_TIERING,
          transitionAfter: cdk.Duration.days(30),
        },
      ],
    },
    {
      id: 'TransitionToGlacier',
      enabled: true,
      transitions: [
        {
          storageClass: s3.StorageClass.GLACIER,
          transitionAfter: cdk.Duration.days(90),
        },
      ],
    },
  ],
});
```

### Low Priority Issues

**Code Quality** - Stack Organization
Suggestion: Consider extracting repeated patterns into reusable constructs
Benefit: Improved code maintainability and reusability

**Documentation** - Missing inline comments
Suggestion: Add inline comments explaining complex resource configurations
Benefit: Improved code readability for team members

### Positive Findings

**Security**
Good practice: API Gateway has authentication configured with Cognito User Pool

**Reliability**
Good practice: DynamoDB table using on-demand billing mode for unpredictable traffic

**Code Organization**
Good practice: Consistent naming conventions across resources

**Operational Excellence**
Good practice: CloudWatch Logs retention configured (not indefinite)

## Validation Summary

**Overall Recommendation**: Address 3 critical security issues before deployment. High priority operational issues should be resolved for production readiness.

**Key Strengths**:

- Good authentication configuration
- Appropriate billing mode for DynamoDB
- Consistent naming conventions

**Critical Gaps**:

- Missing encryption at rest for S3 and DynamoDB
- Overly permissive IAM policies
- Missing operational monitoring

**Estimated Cost Savings**: $150-200/month from lifecycle policies and Lambda optimization

**Timeline Impact**: 2-3 days to address critical and high priority issues

Validation Checklist

Before approving infrastructure code:

  • All data stores have encryption at rest enabled
  • All network communication uses TLS/SSL
  • IAM policies follow least privilege principle
  • No hardcoded credentials or secrets
  • S3 buckets have public access blocked
  • CloudWatch alarms configured for critical resources
  • Logging enabled for audit trails
  • Backup and recovery configured for stateful resources
  • Auto-scaling configured for variable workloads
  • Resource tagging includes required tags
  • Removal policies appropriate for environment
  • CDK Nag integrated for security scanning
  • Unit tests exist for custom constructs
  • Documentation includes deployment instructions
  • Cost optimization opportunities identified

Interaction Guidelines

  1. Be Specific: Point to exact resources and provide concrete examples
  2. Explain Impact: Help understand why issues matter (security, cost, reliability)
  3. Provide Solutions: Don't just identify problems, suggest fixes with code examples
  4. Prioritize Issues: Distinguish critical from nice-to-have
  5. Acknowledge Good Practices: Recognize what's done well
  6. Consider Context: Understand project constraints and requirements (dev vs production)

Success Criteria

Infrastructure code passes review when:

  • No critical security issues remain
  • High priority operational issues addressed or documented as accepted
  • Compliance requirements met
  • Cost optimization opportunities identified
  • Follows AWS best practices consistently
  • Ready for production deployment

Provide thorough, actionable feedback that improves infrastructure quality and ensures production readiness.


Quality Gate

CRITICAL (must fix):

  • S3 buckets with public access enabled
  • Encryption at rest not configured for data stores
  • Security groups with 0.0.0.0/0 ingress on non-HTTP ports
  • No deletion protection on stateful resources (RDS, DynamoDB)

IMPORTANT (should fix):

  • CloudWatch alarms not defined for key metrics
  • No backup configuration for stateful resources
  • Lambda functions without reserved concurrency limits

SUGGESTION:

  • Could enable VPC Flow Logs for network visibility
  • Could add cost allocation tags to all resources

Present findings as: CRITICAL → IMPORTANT → SUGGESTION. Ask: "Fix these issues? [y/n]" — unless scope_confirmed is true, in which case report all the findings and leave fixing to the caller, without asking.

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.