56 results available
Sign in
Skills directory

aws-resource-health-diagnose

github

·

Last changed
Not yet hardened

This version isn't hardened by Chainguard

No hardening report available.


SKILL.md

AWS Resource Health & Issue Diagnosis

This workflow analyzes a specific AWS resource to assess its health status, diagnose potential issues using CloudWatch logs and metrics, and develop a comprehensive remediation plan for any problems discovered.

Prerequisites

  • AWS CLI configured and authenticated
  • Target AWS resource identified (name, type, and optionally region/account)
  • CloudWatch logging and metrics enabled on the target resource

Security Requirements

Workflow Steps

Step 1: Review Diagnostic Heuristics

Key CloudWatch Diagnostic Principles (embedded):

  • Establish a baseline first. Compare current metrics against historical averages before classifying an anomaly. A spike may be normal for peak hours.
  • Correlate metrics with events. Cross-reference CloudWatch metric changes against CloudTrail API events and deployment timestamps to identify causal changes.
  • Check log stream freshness. If no recent log entries exist, determine whether logging is enabled and the log group is receiving data before concluding the service is healthy.
  • Prefer Logs Insights over metric math for root cause analysis on Lambda and ECS; metric statistics show what happened, logs show why.
  • For RDS, always check Performance Insights db.load.avg and DatabaseConnections before recommending a reboot; connection exhaustion often has a pool-configuration root cause that a reboot will not permanently fix.
  • For throttling findings, verify whether the throttle is account-level or function-level before adjusting reserved concurrency; account-level throttles require a service quota increase, not a concurrency setting.

Step 2: Resource Discovery & Identification

Locate the target resource using the appropriate AWS CLI command for its type:

# EC2
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws ec2 describe-instances --filters "Name=tag:Name,Values=${RESOURCE_NAME}"

# Lambda
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws lambda get-function --function-name "${RESOURCE_NAME}"

# RDS
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws rds describe-db-instances --db-instance-identifier "${RESOURCE_NAME}"

# ECS
CLUSTER_NAME="<cluster>"   # Agent substitutes the validated identifier here
RESOURCE_NAME="<name>"     # Agent substitutes the validated identifier here
aws ecs describe-services --cluster "${CLUSTER_NAME}" --services "${RESOURCE_NAME}"

# ALB
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws elbv2 describe-load-balancers --names "${RESOURCE_NAME}"

# DynamoDB
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws dynamodb describe-table --table-name "${RESOURCE_NAME}"

# SQS
QUEUE_URL="<url>"   # Agent substitutes the validated queue URL here
aws sqs get-queue-attributes --queue-url "${QUEUE_URL}" --attribute-names All

# API Gateway
aws apigatewayv2 get-apis

If multiple matches are found, prompt the user to specify region/account.

Step 3: Health Status Assessment

Run service-specific health checks:

# EC2
INSTANCE_ID="<id>"   # Agent substitutes the validated identifier here
aws ec2 describe-instance-status --instance-ids "${INSTANCE_ID}"

# RDS
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws rds describe-db-instances --db-instance-identifier "${RESOURCE_NAME}" \
  --query 'DBInstances[0].DBInstanceStatus'

# Lambda - error rate over 24h
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
START_TIME=$(python3 -c "import datetime; print((datetime.datetime.utcnow() - datetime.timedelta(hours=24)).strftime('%Y-%m-%dT%H:%M:%SZ'))")
END_TIME=$(python3 -c "import datetime; print(datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'))")
aws cloudwatch get-metric-statistics --namespace AWS/Lambda \
  --metric-name Errors --dimensions "Name=FunctionName,Value=${RESOURCE_NAME}" \
  --start-time "${START_TIME}" \
  --end-time "${END_TIME}" \
  --period 3600 --statistics Sum

# ECS
CLUSTER_NAME="<cluster>"   # Agent substitutes the validated identifier here
RESOURCE_NAME="<name>"     # Agent substitutes the validated identifier here
aws ecs describe-services --cluster "${CLUSTER_NAME}" --services "${RESOURCE_NAME}" \
  --query 'services[0].[status,runningCount,desiredCount,pendingCount]'

Key health indicators by service type:

  • Lambda: Error rate, throttle rate, duration P99, concurrent executions
  • RDS: CPU utilization, FreeStorageSpace, DatabaseConnections, ReadLatency/WriteLatency
  • ECS: Running vs desired task count, task stop reason
  • ALB: TargetResponseTime, HTTPCode_ELB_5XX_Count, UnHealthyHostCount
  • SQS: ApproximateNumberOfMessagesNotVisible, ApproximateAgeOfOldestMessage
  • DynamoDB: ConsumedReadCapacityUnits, ThrottledRequests, SuccessfulRequestLatency

Step 4: Log & Metrics Analysis

Find log groups and run CloudWatch Logs Insights queries:

# Find log groups
SERVICE_NAME="<service>"   # Agent substitutes the validated service name here
RESOURCE_NAME="<name>"     # Agent substitutes the validated identifier here
aws logs describe-log-groups --log-group-name-prefix "/aws/${SERVICE_NAME}/${RESOURCE_NAME}"

# Start a query (last 24h errors)
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
START_EPOCH=$(( $(python3 -c "import time; print(int(time.time()))") - 86400 ))
END_EPOCH=$(python3 -c "import time; print(int(time.time()))")
aws logs start-query \
  --log-group-name "/aws/lambda/${RESOURCE_NAME}" \
  --start-time "${START_EPOCH}" \
  --end-time "${END_EPOCH}" \
  --query-string 'filter @message like /ERROR/ | stats count(*) as errorCount by bin(1h)'

# Get results
QUERY_ID="<id>"   # Agent substitutes the query ID returned by start-query
aws logs get-query-results --query-id "${QUERY_ID}"

# Lambda cold starts
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
START_EPOCH=$(( $(python3 -c "import time; print(int(time.time()))") - 86400 ))
END_EPOCH=$(python3 -c "import time; print(int(time.time()))")
aws logs start-query \
  --log-group-name "/aws/lambda/${RESOURCE_NAME}" \
  --start-time "${START_EPOCH}" \
  --end-time "${END_EPOCH}" \
  --query-string 'filter @type = "REPORT" | filter @initDuration > 0 | stats count() as coldStarts by bin(1h)'

# RDS Performance Insights (if enabled)
DB_IDENTIFIER="<identifier>"   # Agent substitutes the validated identifier here
START_TIME=$(python3 -c "import datetime; print((datetime.datetime.utcnow() - datetime.timedelta(hours=24)).strftime('%Y-%m-%dT%H:%M:%SZ'))")
END_TIME=$(python3 -c "import datetime; print(datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'))")
aws pi get-resource-metrics \
  --service-type RDS --identifier "db:${DB_IDENTIFIER}" \
  --metric-queries '[{"Metric":"db.load.avg"}]' \
  --start-time "${START_TIME}" \
  --end-time "${END_TIME}" \
  --period-in-seconds 3600

Identify: recurring error patterns, correlation with deployments (CloudTrail), performance trends, dependency failures.

Step 5: Issue Classification & Root Cause Analysis

Severity:

  • Critical: Service unavailable, data loss, security incidents
  • High: Performance degradation, error rates >5%, intermittent failures
  • Medium: Warnings, suboptimal configuration, minor performance issues
  • Low: Informational alerts, optimization opportunities

Root Cause Categories:

  • Configuration Issues: wrong settings, missing env vars, IAM permission denials
  • Resource Constraints: CPU/memory/disk limits, Lambda throttling, RDS connection exhaustion
  • Network Issues: security group rules, VPC routing, DNS, NACLs
  • Application Issues: code bugs, memory leaks, unhandled exceptions, slow queries
  • Dependency Issues: downstream timeouts, SQS/SNS failures, external API limits
  • Security Issues: KMS key issues, certificate expiration

Step 6: Generate Remediation Plan

Immediate Actions (Critical — requires confirmation in Step 6b before execution):

  • Lambda throttling: increase reserved concurrency
  • RDS connection exhaustion: reboot instance to reset connections

Short-term Fixes (High/Medium): Configuration adjustments, right-sizing, CloudWatch alarm improvements, IAM corrections.

Long-term Improvements: Architectural changes for resilience, preventive monitoring, enable AWS Health Dashboard notifications via EventBridge.


Step 6b: Remediation Execution (Write Operations — Explicit Confirmation Required)

[Execute? y/n required before each command]

# ACTION 1 of 2: Lambda throttling — increase reserved concurrency
# Impact: Limits maximum concurrent Lambda invocations. Review current account-level concurrency limits before applying.
# Verify this is a function-level throttle (not account-level) before proceeding; account-level throttles require a service quota increase instead.
# Ask the user: "Do you want to set reserved concurrency to 100 for Lambda function <name>? (y/n)"
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws lambda put-reserved-concurrency \
  --function-name "${RESOURCE_NAME}" \
  --reserved-concurrent-executions 100
# ACTION 2 of 2: RDS connection exhaustion — reboot instance to reset connections
# Impact: ⛔ PRODUCTION DISRUPTION. Causes 30–120 seconds of database downtime.
# Coordinate with application teams before executing. Prefer connection pool configuration fixes if possible, as a reboot will not permanently resolve a pool misconfiguration.
# Ask the user: "Do you want to reboot the RDS instance <name>? This will cause a temporary outage. (y/n)"
RESOURCE_NAME="<name>"   # Agent substitutes the validated identifier here
aws rds reboot-db-instance --db-instance-identifier "${RESOURCE_NAME}"

Step 7: Report & User Confirmation

Present findings:

🏥 AWS Resource Health Assessment

📊 Resource Overview:
• Resource: [Name] ([Type])
• Status: [Healthy/Warning/Critical]
• Region: [Region] | Account: [Account ID]

🚨 Issues Identified:
• Critical: X | High: Y | Medium: Z | Low: N

🔍 Top Issues:
1. [Issue]: [Description] — Impact: [High/Medium/Low]
2. [Issue]: [Description] — Impact: [High/Medium/Low]

🛠️ Remediation: X immediate, Y short-term, Z long-term actions

❓ Proceed with detailed remediation plan? (y/n)

Then generate a full markdown report covering: health metrics, issues with root cause analysis, phased remediation steps with AWS CLI commands, CloudWatch alarm recommendations, and validation checklist.

Error Handling

  • Resource Not Found: Ask user to clarify name/region

  • Authentication Issues: Guide through aws configure

  • Insufficient Permissions: The following IAM actions are the minimum required. Grant only what is needed for your specific resource type:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "AWSResourceHealthDiagnoseReadOnly",
          "Effect": "Allow",
          "Action": [
            "ec2:DescribeInstances",
            "ec2:DescribeInstanceStatus",
            "lambda:GetFunction",
            "rds:DescribeDBInstances",
            "ecs:DescribeServices",
            "elasticloadbalancing:DescribeLoadBalancers",
            "dynamodb:DescribeTable",
            "sqs:GetQueueAttributes",
            "apigateway:GET",
            "cloudwatch:GetMetricStatistics",
            "cloudwatch:ListMetrics",
            "logs:DescribeLogGroups",
            "logs:StartQuery",
            "logs:GetQueryResults",
            "pi:GetResourceMetrics"
          ],
          "Resource": "*"
        }
      ]
    }
  • No Logs Available: Suggest enabling CloudWatch logging for the resource type

  • Query Timeouts: Use shorter time windows

Success Criteria

  • ✅ Resource health accurately assessed across all key metrics
  • ✅ All significant issues identified and classified by severity
  • ✅ Root cause analysis completed for major problems
  • ✅ Actionable remediation plan with AWS CLI commands
  • ✅ CloudWatch monitoring recommendations included
  • ✅ Implementation steps include validation and rollback procedures

Install

Need this version hardened?

Harden your own skills

Bring Chainguard's hardening pipeline to your first-party skills — custom rulesets, automated remediation, full audit trail.

Provenance

Upstream source

—

Upstream commitd93e8cf931faf134467564952a682f7bec4a141c
OCI reference

—

License

MIT

Files

HARDENING.md

LICENSE

SKILL.md


The trusted source for open source

Talk to an expert
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsChainguard OS PackagesChainguard ActionsChainguard Agent SkillsIntegrationsPricing
© 2026 Chainguard, Inc. All Rights Reserved.
Chainguard® and the Chainguard logo are registered trademarks of Chainguard, Inc. in the United States and/or other countries.
The other respective trademarks mentioned on this page are owned by the respective companies and use of them does not imply any affiliation or endorsement.