AWS Orphaned Resource Detector and Cost Optimizer - n8n Workflow

An essential n8n workflow for FinOps teams. Automatically detect unattached AWS resources (EBS volumes, snapshots, Elastic IPs) weekly, calculate monthly waste, and send detailed reports via Slack, Gmail, and Google Sheets. Utilize this powerful n8n template to drive cloud cost efficiency.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Cloud Cost Optimization teams (FinOps).

  • DevOps engineers needing automated compliance and resource tracking.

  • System Administrators managing large multi-region AWS environments.

  • Users looking for complex, scheduled n8n templates for infrastructure monitoring.

Overview

Managing sprawling cloud infrastructure requires constant vigilance to prevent 'cloud waste.' Orphaned resources, such as unattached EBS volumes or old snapshots, often accumulate significant unexpected costs. This sophisticated n8n workflow solves this by running a comprehensive weekly audit.

Built as a robust n8n template, it uses AWS Lambda functions to securely identify non-compliant and unused assets across specified regions. The data is processed within the n8n node logic to calculate potential monthly and annual savings and check for mandatory resource tags (e.g., Owner, CostCenter). Whether waste is found or the scan is clean, the process provides transparency by sending immediate alerts to Slack, emailing a detailed HTML report (via Gmail), and maintaining an auditable log in Google Sheets. Implementing this n8n automation is a critical step for serious cloud cost control.

How it Works

The entire process is initiated by the Weekly Scan Trigger1, a scheduled n8n trigger set to run every Monday.


  1. Configuration: The workflow starts by initializing configuration variables in the Initialize Config n8n node, defining target AWS regions, required tagging policies, and recipient details.

  2. Parallel Scanning: The flow executes three parallel AWS Lambda n8n node calls to invoke a pre-deployed Lambda function in AWS for scanning Unattached EBS Volumes, Old Snapshots, and Unassociated Elastic IPs across the configured regions.

  3. Data Processing: Three corresponding Code n8n node steps (Process EBS Volumes, Process Snapshots, Process Elastic IPs) normalize the raw Lambda output. This involves calculating individual resource costs based on configured rates and checking for missing required tags.

  4. Aggregation & Summary: The Aggregate All Resources n8n node collects the processed data. The Calculate Summary Stats n8n node then computes total monthly/annual waste costs, determines the compliance rate, and ranks the top 5 most expensive orphaned resources.

  5. Conditional Reporting: The If Resources Found n8n node directs the flow based on whether any orphaned resources were detected.

Resources Found (True): The flow proceeds to generate a professional HTML report (Generate HTML Report), sends an immediate summary alert via the Send Slack Alert n8n node, and logs the detailed summary metrics into a Google Sheet.
Clean Scan (False): The flow sends an "All Clear" message via the None Found Slack Message n8n node and logs a 'CLEAN' entry to a Google Sheet, ensuring a complete audit trail of the n8n workflow execution.

Installation Guide

To install and utilize this n8n workflow template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. AWS Prerequisites: Ensure you have deployed the necessary AWS Lambda function (aws-orphaned-resource-scanner) and configured an IAM user with appropriate EC2 read and Lambda invoke permissions.

  3. Credential Setup: Connect the required services to the respective n8n node types:

AWS: Connect your IAM user credentials to the AWS Lambda nodes.
Slack: Configure credentials or a webhook URL for the Slack n8n node.
Gmail: Configure Gmail OAuth2 credentials for the Send Email Report n8n node.
Google Sheets: Configure Google Sheets OAuth2 credentials and ensure the target spreadsheet and sheet name exist (e.g., 'Clean Scans' sheet).

  1. Workflow Configuration: Update the Initialize Config n8n node parameters, paying close attention to:

awsRegions: List all regions to scan.
slackChannel and emailRecipients: Set the correct destination targets.
* requiredTags: Customize the tags you enforce for compliance.

  1. Activate: Test the entire n8n workflow using 'Execute Workflow' to verify all outputs, and then toggle the workflow to 'Active' so the Schedule Trigger runs automatically.

Node Details


  • Weekly Scan Trigger1 (Schedule Trigger): This n8n trigger is set to run the entire n8n workflow weekly, ensuring continuous cost monitoring.

  • Initialize Config (Set n8n node): Central configuration hub. Key parameters include defining target awsRegions (e.g., us-east-1, us-west-2) and cost factors.

  • Scan EBS Snapshots / Volumes / Elastic IPs (AWS Lambda n8n node): Invokes the external AWS Lambda function (aws-orphaned-resource-scanner) for secure data collection from the cloud environment.

  • Process Nodes (Code n8n node): Three separate Code nodes calculate the monthly cost for each resource type (volumes, snapshots, IPs) and attach compliance status (missing tags) to each item. This logic is core to the n8n workflow's cost analysis.

  • Calculate Summary Stats (Code n8n node): A critical n8n node that aggregates data, calculates overall financial waste (annual cost), and structures the output for reporting (top 5 expenses, compliance rate).

  • If Resources Found (If n8n node): A flow control n8n node that splits the automation based on whether totalResourcesFound is greater than zero.

  • Send Slack Alert (Slack n8n node): Provides immediate notification of waste, summarizing the annual cost impact and listing the top offenders. Uses data derived from the Calculate Summary Stats n8n node.

  • Send Email Report (Gmail n8n node): Dispatches a full, professional HTML report generated within the n8n workflow to the FinOps team.

  • Log to Google Sheets (Google Sheets n8n node): Appends scan metrics (cost, resource counts, compliance) to a specified Google Sheet, creating a historical audit trail of the n8n automation's findings.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by

DevOps/SRE consultant and Kubernetes educator helping teams automate workflows with n8n. I create practical automation templates for infrastructure, monitoring, and business processes. Check out the KubeSkills YouTube channel for hands-on Kubernetes tutorials, or book a consultation for custom automation work.

Featured*