⚙️ Detect AWS Orphaned Resources & Send Cost Reports to Slack, Email, and Sheets

162 views · ⚙️ DevOps & CI/CD

Description

How it works

This workflow automatically scans AWS accounts for orphaned resources (unattached EBS volumes, old snapshots >90 days, unassociated Elastic IPs) that waste money. It calculates cost impact, validates compliance tags, and sends multi-channel alerts via Slack, Email, and Google Sheets audit logs.

Key Features:

What gets detected:

Typical savings: $50-10K/month depending on account size

Set up steps

Prerequisites

AWS Configuration:

  1. Create IAM user n8n-resource-scanner with these permissions:
    • ec2:DescribeVolumes
    • ec2:DescribeSnapshots
    • ec2:DescribeAddresses
    • ec2:DescribeInstances
    • lambda:InvokeFunction
  2. Deploy Lambda function aws-orphaned-resource-scanner (Node.js 18+)
  3. Add EC2 read-only permissions to Lambda execution role
  4. Generate AWS Access Key + Secret Key

Lambda Function Code: See sticky notes in workflow for complete implementation using @aws-sdk/client-ec2

Credentials Required:

Configuration

  1. Initialize Config Node: Update these settings:

    • awsRegions: Your AWS regions (default: us-east-1)
    • emailRecipients: FinOps team emails
    • slackChannel: Alert channel (e.g., #cloud-ops)
    • requiredTags: Compliance tags to validate
    • snapshotAgeDays: Age threshold (default: 90)
  2. Set Region Variables: Choose regions to scan

  3. Lambda Function: Deploy function with provided code (see workflow sticky notes)

  4. Google Sheet: Create spreadsheet with headers:

    • Scan Date | Region | Resource Type | Resource ID | Monthly Cost | Compliance | etc.
  5. Credentials: Connect all four credential types in n8n

  6. Schedule: Enable “Weekly Scan Trigger” (default: Mondays 8 AM UTC)

Testing

  1. Click “Execute Workflow” to run manual test
  2. Verify Lambda invokes successfully
  3. Check Slack alert appears
  4. Confirm email with HTML report received
  5. Validate Google Sheets logging works

Customization Options

Use Cases

Resources

🔗 Nodes Used

Google Sheets, Slack, AWS Lambda, Gmail, Schedule Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup