Skip to content

fix(extractor): resolve region from provider config for real AWS plans#2

Merged
omrdev1 merged 1 commit into
mainfrom
e2e/live-aws-test
Mar 26, 2026
Merged

fix(extractor): resolve region from provider config for real AWS plans#2
omrdev1 merged 1 commit into
mainfrom
e2e/live-aws-test

Conversation

@omrdev1
Copy link
Copy Markdown
Owner

@omrdev1 omrdev1 commented Mar 26, 2026

What

Fixes a bug found during live E2E testing against a real AWS account where all resources were being skipped as known_after_apply.

Root cause

Real terraform plan output sets region on the provider block, not on individual resources. The extractor was exhausting all resource-level region lookups (arn, availability_zone, region attribute) and falling back to known_after_apply, skipping everything.

Changes

  • extractProviderRegion() — reads configuration.provider_config.aws.expressions.region.constant_value
  • resolveRegion() — adds provider region as 5th fallback
  • plannedValuesMap — fallback for instance type from planned_values block
  • TerraformPlan interface for proper typing
  • fixtures/tfplan.e2e.json — real AWS plan fixture (credentials stripped)
  • .github/workflows/greenops-e2e.yml — live Action e2e test

Verified

Tested against a live terraform plan on a real AWS account:

🌱 GreenOps Infrastructure Impact

┌──────────────────────┬───────────────┬───────────────┬───────────────┬───────────────┐
│ Resource             │ Instance      │ Region        │ CO2e/mo       │ Action        │
├──────────────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
│ aws_instance.web     │ m5.large      │ us-east-1     │ 4.31kg        │ UPGRADE       │
│ aws_instance.worker  │ m6g.large     │ us-east-1     │ 2.74kg        │ UPGRADE       │
└──────────────────────┴───────────────┴───────────────┴───────────────┴───────────────┘

Current: 7.06kg | $126.29
Savings: -2.60kg | -$13.87

Real terraform plans set region on the provider block, not individual
resources. The extractor was exhausting all resource-level lookups and
falling back to known_after_apply, causing all resources to be skipped.

Changes:
- Add extractProviderRegion() — reads configuration.provider_config
- Add providerRegion as 5th fallback in resolveRegion()
- Add plannedValuesMap fallback for instance_type resolution
- Add TerraformPlan interface for proper typing

Also adds:
- fixtures/tfplan.e2e.json — real AWS plan fixture (credentials stripped)
- .github/workflows/greenops-e2e.yml — live Action e2e test on PRs
@github-actions
Copy link
Copy Markdown

🌱 GreenOps Infrastructure Impact

Total Current Footprint: 7.06kg CO2e/month | $126.29/month
Potential Savings: -2.60kg CO2e/month (36.8%) | -$13.87/month
💡 Found 2 optimization recommendations.

Resource Breakdown

Resource Type Region CO2e/month Cost/month Action
aws_instance.web m5.large us-east-1 4.31kg $70.08 💡 View Recommendation
aws_instance.worker m6g.large us-east-1 2.74kg $56.21 💡 View Recommendation

Recommendations

aws_instance.web

  • Current: m5.large in us-east-1
  • Suggested: m6g.large in us-east-1
  • Impact: -1.57kg CO2e/month | -$13.87/month
  • Rationale: Switching from m5.large (x86_64) to m6g.large (ARM64) provides identical vCPU and memory at lower power draw, reducing carbon by 1570g CO2e/month and cost by $13.87/month.

aws_instance.worker

  • Current: m6g.large in us-east-1
  • Suggested: m6g.large in us-west-2
  • Impact: -1.03kg CO2e/month | +$0.00/month
  • Rationale: Moving m6g.large from us-east-1 to US West (Oregon) (us-west-2) reduces grid carbon intensity from 384.5g to 240.1g CO2e/kWh, saving 1030g CO2e/month saving $0.00/month.

Emissions calculated using the Open GreenOps Methodology Ledger (v1.1.0). Scope 2 operational emissions only — embodied carbon and water are not tracked. Math is MIT-licensed and auditable. Analysed at 2026-03-26T23:11:16.876Z. Learn more.

🏢 Managing green-ops across dozens of repositories? Upgrade to GreenOps Dashboard to aggregate CI/CD carbon data natively.

@omrdev1 omrdev1 merged commit 561ffb3 into main Mar 26, 2026
1 check passed
@omrdev1 omrdev1 deleted the e2e/live-aws-test branch March 27, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant