{"product_id":"detect-aws-cost-spikes-auto-create-terraform-fix-prs","title":"Detect AWS Cost Spikes \u0026 Auto-Create Terraform Fix PRs","description":"\u003ch3\u003eAutomatically detect AWS Cost Explorer spend spikes and ship Terraform fix PRs\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow monitors your AWS daily spend using \u003cstrong\u003eAWS Cost Explorer\u003c\/strong\u003e, detects cost spikes, correlates them to the latest relevant Terraform change in \u003cstrong\u003eGitHub\u003c\/strong\u003e, and then uses \u003cstrong\u003eOpenAI\u003c\/strong\u003e to draft a root-cause analysis and corrected Terraform file—automatically opening a \u003cstrong\u003eGitHub pull request\u003c\/strong\u003e and posting results to \u003cstrong\u003eSlack\u003c\/strong\u003e.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRuns on a schedule (every 6 hours)\u003c\/strong\u003e or via manual trigger, with configurable repository, Terraform path, thresholds, and analysis date ranges.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eQueries AWS Cost Explorer\u003c\/strong\u003e for daily unblended cost by AWS service over the last 8 days, calculates today’s spend vs a rolling baseline average, and compares the percent increase to your configured threshold.\u003c\/li\u003e\n  \u003cli\u003eIf the increase exceeds the threshold, it identifies the \u003cstrong\u003etop contributing AWS service\u003c\/strong\u003e and continues; otherwise, the run stops.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eUses the GitHub API\u003c\/strong\u003e to list recent commits that touched the target Terraform file and selects the most recent commit as the likely source of the change.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFetches the current Terraform file from GitHub\u003c\/strong\u003e and sends cost spike metrics, suspect commit details, and file content to \u003cstrong\u003eOpenAI\u003c\/strong\u003e to generate a root-cause summary, fix description, and a complete corrected Terraform file.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCreates a new GitHub branch\u003c\/strong\u003e, commits the updated Terraform file, opens a pull request, and posts a \u003cstrong\u003eSlack\u003c\/strong\u003e message containing the cost impact, analysis, and PR link.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003ePrevent AWS cost regressions after Terraform changes by detecting spikes early and responding with an automated fix PR.\u003c\/li\u003e\n  \u003cli\u003eFor SaaS operators, reduce time-to-diagnosis when a sudden spend increase points to a specific infrastructure change.\u003c\/li\u003e\n  \u003cli\u003eFor automation engineers, standardize cost incident handling with GitHub PRs and Slack notifications.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAWS integration:\u003c\/strong\u003e Requires AWS credentials with \u003cstrong\u003ece:GetCostAndUsage\u003c\/strong\u003e permissions (Cost Explorer calls made in \u003cstrong\u003eus-east-1\u003c\/strong\u003e).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGitHub integration:\u003c\/strong\u003e Uses GitHub API to inspect commits, create branches, and open pull requests.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOpenAI:\u003c\/strong\u003e Generates root-cause analysis and a corrected Terraform file.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSlack:\u003c\/strong\u003e Posts results, cost impact, and PR link.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n nodes \/ tools mentioned:\u003c\/strong\u003e if, set, code, wait, slack, sticky note.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45822087889075,"sku":"N8N-18094","price":51.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/I-_AgtLXk6E6tmuCuoT7O_NO51chiP.png?v=1786525363","url":"https:\/\/buyflowscripts.com\/products\/detect-aws-cost-spikes-auto-create-terraform-fix-prs","provider":"N8N Commerce","version":"1.0","type":"link"}