How co-cddo/terraform-azure-focus works
terraform-azure-focus provisions an Azure cost-export solution and its Python Function App forwards cost, Advisor, and carbon datasets to AWS S3. The principal runtime flow is timer/HTTP-triggered Function App work: cost backfill schedules and runs Cost Management exports; Advisor and carbon handlers retrieve their data and write exports. Shared billing discovery, credentials, and S3 access support these paths. Terraform resource roles are based on the README; runtime links use shown imports/calls or documented capabilities, with unsampled wiring left out.
Main entry points: s3Api.py S3 Access · function_app.py Function Triggers · main.tf Terraform Module · carbonExport.py Carbon Export
Components 22
Azure Deployment
- Terraform Module
main.tf - Function App
function_app.tf - Azure Storage
storage.tf - Event Grid
event_grid.tf - Private Networking
private_endpoints.tf
FOCUS Cost
- Function Triggers
src/cost_export/function_app.py - Cost Backfill
src/cost_export/costExport.py - Cost Management API
src/cost_export/api/costMgmtApi.py - Backfill State
src/cost_export/api/costMgmtS3Api.py
Advisor Data
- Advisor Export
src/cost_export/function_app.py
Carbon Data
- Carbon Export
src/cost_export/carbonExport.py - Carbon API
src/cost_export/carbonExport.py - Carbon State
src/cost_export/api/carbonS3Api.py
Shared Services
- Billing Discovery
src/cost_export/billing.py - Token Manager
src/cost_export/api/tokens.py - Runtime Config
src/cost_export/common.py - S3 Access
src/cost_export/api/s3Api.py
Other components
- Deployer
- AWS S3
- Azure Cost Management
- Azure Advisor
- Carbon Optimization API
Connections 26
- Deployer → Terraform Module: applies
README.md - Terraform Module → Function App: provisions
README.md - Terraform Module → Azure Storage: provisions
README.md - Terraform Module → Event Grid: provisions
README.md - Terraform Module → Private Networking: provisions
README.md - Function Triggers → Cost Backfill: dispatches
src/cost_export/function_app.py - Function Triggers → Carbon Export: dispatches
src/cost_export/function_app.py - Function Triggers → Billing Discovery: calls
src/cost_export/function_app.py - Function Triggers → Advisor Export: runs
src/cost_export/function_app.py - Cost Backfill → Cost Management API: manages exports
src/cost_export/costExport.py - Cost Backfill → Backfill State: checks state
src/cost_export/costExport.py - Cost Management API → Azure Cost Management: requests exports
src/cost_export/api/costMgmtApi.py - Backfill State → S3 Access: uses filesystem
src/cost_export/api/costMgmtS3Api.py - Carbon Export → Billing Discovery: finds subscriptions
src/cost_export/carbonExport.py - Carbon Export → Carbon State: checks locks
src/cost_export/carbonExport.py - Carbon Export → Carbon Optimization API: requests emissions
src/cost_export/carbonExport.py - Carbon Export → S3 Access: writes exports
src/cost_export/carbonExport.py - Carbon State → S3 Access: uses filesystem
src/cost_export/api/carbonS3Api.py - Advisor Export → Azure Advisor: requests recommendations
src/cost_export/function_app.py - Function Triggers → S3 Access: uploads data
src/cost_export/function_app.py - Billing Discovery → Token Manager: gets token
src/cost_export/billing.py - S3 Access → Token Manager: gets credentials
src/cost_export/api/s3Api.py - Token Manager → Runtime Config: reads settings
src/cost_export/api/tokens.py - S3 Access → Runtime Config: reads settings
src/cost_export/api/s3Api.py - S3 Access → AWS S3: reads and writes
src/cost_export/api/s3Api.py - Function App → Function Triggers: hosts