Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,36 @@ Fixed

## [0.3.25] - 2025-07-02

### Fixed
### Added

- Fixed budget amount calculation for projects using monthly budget data entries
- Resolved perpetual drift issue where Terraform would detect changes in budget amounts
- Added proper handling for Kion API responses that omit the 'amount' field when using monthly data
- Added validation to ensure monthly budget data totals match the declared budget amount
- Fixed floating-point precision issues causing false drift detection (e.g., 5000.000000000001)
- Added detection for auto-generated monthly budget entries to prevent false drift
#### Resources

### Added
- `kion_billing_source_aws` - Manage AWS commercial billing sources with support for CUR, DBR, and FOCUS reports
- `kion_billing_source_aws_govcloud` - Manage AWS GovCloud billing sources with dedicated account type support
- `kion_billing_source_gcp` - Manage GCP billing sources with BigQuery export configuration
- `kion_billing_source_oci` - Manage OCI billing sources for commercial, government, and federal tenancies

#### Data Sources

- `kion_billing_sources` - Query multiple billing sources with filtering support

#### Models

- Billing source models for AWS, AWS GovCloud, GCP, and OCI with comprehensive field support

#### Features

- Budget amount validation during plan phase using CustomizeDiff
- Helper functions for budget calculations: `IsAutoGeneratedBudgetData()`, `AlmostEqual()`, `roundToTwoDecimals()`
- Clear error messages when monthly budget totals don't match declared amounts
- Support for multiple cloud providers (AWS, GCP, OCI) with provider-specific configurations
- FOCUS report support for modern FinOps workflows
- Proprietary report support (CUR, DBR for AWS)
- Cross-account billing bucket access with IAM roles
- Account creation enablement for automated provisioning
- Validation for account numbers, date formats, and region specifications

### Changed

- Improved budget amount field description to clarify validation requirements
- Updated provider to register all new billing source resources and data sources
- Added support for v4 billing source API endpoints

## [0.3.24] - 2024-05-08

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This Makefile is an easy way to run common operations.

VERSION=0.3.25
VERSION=0.3.26-dev

TEST?=$$(go list ./... | grep -v 'vendor')
HOSTNAME=github.com
Expand Down
94 changes: 94 additions & 0 deletions docs/data-sources/billing_sources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "kion_billing_sources Data Source - terraform-provider-kion"
subcategory: ""
description: |-

---

# kion_billing_sources (Data Source)



## Example Usage

```terraform
# Example: Get all billing sources
data "kion_billing_sources" "all" {
}

# Example: Filter billing sources by name
data "kion_billing_sources" "production" {
filter {
name = "name"
values = ["Production*"]
regex = true
}
}

# Example: Filter billing sources by type
data "kion_billing_sources" "aws_sources" {
filter {
name = "type"
values = ["aws"]
}
}

# Example: Filter billing sources that support account creation
data "kion_billing_sources" "account_creation_enabled" {
filter {
name = "account_creation"
values = ["true"]
}
}

# Output examples
output "all_billing_sources" {
value = data.kion_billing_sources.all.list
}

output "production_billing_sources" {
value = data.kion_billing_sources.production.list
}

output "aws_billing_source_names" {
value = [for source in data.kion_billing_sources.aws_sources.list : source.name]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `filter` (Block List) (see [below for nested schema](#nestedblock--filter))

### Read-Only

- `id` (String) The ID of this resource.
- `list` (List of Object) This is where Kion makes the discovered data available as a list of resources. (see [below for nested schema](#nestedatt--list))

<a id="nestedblock--filter"></a>
### Nested Schema for `filter`

Required:

- `name` (String) The field name whose values you wish to filter by.
- `values` (List of String) The values of the field name you specified.

Optional:

- `regex` (Boolean) Dictates if the values provided should be treated as regular expressions.


<a id="nestedatt--list"></a>
### Nested Schema for `list`

Read-Only:

- `account_creation` (Boolean)
- `id` (Number)
- `name` (String)
- `type` (String)
- `use_focus_reports` (Boolean)
- `use_proprietary_reports` (Boolean)
127 changes: 127 additions & 0 deletions docs/resources/billing_source_aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "kion_billing_source_aws Resource - terraform-provider-kion"
subcategory: ""
description: |-
Creates and manages an AWS commercial billing source.
AWS billing sources enable cost management and account management capabilities by connecting Kion to AWS billing data. This resource creates commercial AWS billing sources (account type 1).
WARNING: Updates to this resource use a private API endpoint (/v1/payer) that may change without notice. Use at your own risk.
---

# kion_billing_source_aws (Resource)

Creates and manages an AWS commercial billing source.

AWS billing sources enable cost management and account management capabilities by connecting Kion to AWS billing data. This resource creates commercial AWS billing sources (account type 1).

**WARNING**: Updates to this resource use a private API endpoint (/v1/payer) that may change without notice. Use at your own risk.

## Example Usage

```terraform
# Example: Basic AWS billing source with CUR reports
resource "kion_billing_source_aws" "example" {
name = "Production AWS Billing"
aws_account_number = "123456789012"
billing_start_date = "2024-01"
account_creation = true

# CUR configuration
billing_report_type = "cur"
cur_bucket = "my-billing-reports-bucket"
cur_bucket_region = "us-east-1"
cur_name = "my-cost-and-usage-report"
cur_prefix = "reports"
}

# Example: AWS billing source with FOCUS reports
resource "kion_billing_source_aws" "focus_example" {
name = "AWS with FOCUS Reports"
aws_account_number = "987654321098"
billing_start_date = "2024-01"

# FOCUS billing configuration
billing_report_type = "focus"
focus_billing_bucket_account_number = "987654321098"
focus_billing_report_bucket = "my-focus-reports-bucket"
focus_billing_report_bucket_region = "us-east-1"
focus_billing_report_name = "my-focus-report"
focus_billing_report_prefix = "focus-reports"
}

# Example: AWS billing source with IAM role access
resource "kion_billing_source_aws" "role_based" {
name = "AWS with IAM Role Access"
aws_account_number = "111222333444"
billing_bucket_account_number = "555666777888" # Different account holds the billing data
billing_start_date = "2024-01"

# Use IAM role instead of access keys
bucket_access_role = "BillingReportAccessRole"
linked_role = "OrganizationAccountAccessRole"

# CUR configuration
billing_report_type = "cur"
cur_bucket = "cross-account-billing-reports"
cur_bucket_region = "us-east-1"
cur_name = "organization-cur-report"
cur_prefix = "cur"
}

# Example: AWS billing source with access keys
resource "kion_billing_source_aws" "key_based" {
name = "AWS with Access Keys"
aws_account_number = "999888777666"
billing_start_date = "2024-01"

# Authentication via access keys
key_id = var.aws_access_key_id
key_secret = var.aws_secret_access_key

# Skip validation during creation
skip_validation = true

# DBR configuration
billing_report_type = "dbrrt"
detailed_billing_bucket = "detailed-billing-reports"
billing_region = "us-west-2"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `aws_account_number` (String) The AWS account number of the master billing account.
- `billing_start_date` (String) The start date for billing data collection in YYYY-MM format.
- `name` (String) The name of the billing source.

### Optional

- `account_creation` (Boolean) When true, Kion is able to automatically create accounts in this billing source.
- `billing_bucket_account_number` (String) The AWS account number of the S3 bucket holding the billing reports. Defaults to aws_account_number if not specified.
- `billing_region` (String) The region of the S3 bucket holding billing reports (both CUR and DBR reports).
- `billing_report_type` (String) The billing report type to use. Options: 'cur' (AWS Cost and Usage Report), 'dbrrt' (AWS Detailed Billing Report with Resources and Tags), 'focus' (FOCUS billing reports).
- `bucket_access_role` (String) An alternate IAM role for accessing the billing buckets (optional).
- `cur_bucket` (String) The name of the S3 bucket containing the Cost and Usage Reports. Required if billing_report_type is 'cur'.
- `cur_bucket_region` (String) The region of the S3 bucket containing the Cost and Usage Reports. Required if billing_report_type is 'cur'.
- `cur_name` (String) The name of the Cost and Usage Report. Required if billing_report_type is 'cur'.
- `cur_prefix` (String) The report prefix for the Cost and Usage Reports. Required if billing_report_type is 'cur'.
- `detailed_billing_bucket` (String) The name of the S3 bucket containing the detailed billing reports. Required if billing_report_type is 'dbrrt'.
- `focus_billing_bucket_account_number` (String) The AWS account number of the S3 bucket holding the FOCUS reports.
- `focus_billing_report_bucket` (String) The name of the S3 bucket containing the FOCUS reports.
- `focus_billing_report_bucket_region` (String) The region of the S3 bucket containing the FOCUS reports.
- `focus_billing_report_name` (String) The name of the FOCUS billing report.
- `focus_billing_report_prefix` (String) The prefix for the FOCUS billing reports.
- `focus_bucket_access_role` (String) An alternate IAM role for accessing the FOCUS billing buckets (optional).
- `key_id` (String, Sensitive) The AWS Access Key ID used to access the billing S3 bucket.
- `key_secret` (String, Sensitive) The AWS Secret Access Key used to access the billing S3 bucket.
- `linked_role` (String) The name of an existing IAM role that has full administrator permissions. This role will be prefilled as the linked role when creating or importing new accounts under this billing source.
- `skip_validation` (Boolean) When true, will skip validating the connection to the billing source during creation.

### Read-Only

- `id` (String) The ID of this resource.
- `use_focus_reports` (Boolean) True if billing source is configured to read FOCUS reports.
- `use_proprietary_reports` (Boolean) True if billing source is configured to read proprietary billing reports from AWS (CUR, DBRRT).
95 changes: 95 additions & 0 deletions docs/resources/billing_source_gcp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "kion_billing_source_gcp Resource - terraform-provider-kion"
subcategory: ""
description: |-
Creates and manages a GCP (Google Cloud Platform) billing source in Kion.
GCP billing sources are used to import billing data from Google Cloud Platform projects into Kion for cost management and reporting purposes. The billing data is exported from BigQuery where Google Cloud exports billing information.
WARNING: Updates to this resource use a private API endpoint that may change without notice. Use at your own risk.
---

# kion_billing_source_gcp (Resource)

Creates and manages a GCP (Google Cloud Platform) billing source in Kion.

GCP billing sources are used to import billing data from Google Cloud Platform projects into Kion for cost management and reporting purposes. The billing data is exported from BigQuery where Google Cloud exports billing information.

**WARNING**: Updates to this resource use a private API endpoint that may change without notice. Use at your own risk.

## Example Usage

```terraform
# Create a GCP billing source
# Note: You must first create a GCP service account through the Kion UI or API
# and obtain its ID to use in the service_account_id field
resource "kion_billing_source_gcp" "example" {
name = "My GCP Billing Account"
service_account_id = 123 # ID of the GCP service account created in Kion
gcp_id = "012345-ABCDEF-GHIJKL" # Your GCP billing account ID
billing_start_date = "2024-01"

# BigQuery export configuration - where GCP exports billing data
big_query_export {
gcp_project_id = "my-billing-project"
dataset_name = "cloud_billing_export"
table_name = "gcp_billing_export_v1"
table_format = "standard" # Options: auto, standard, detailed
focus_view_name = "focus_view_v1" # Optional: Only if using FOCUS
}

# Optional: Configure billing data format preferences
use_focus = true # Use FOCUS format for cost data
use_proprietary = true # Use GCP proprietary billing format
is_reseller = false # Set to true if this is a reseller billing account
}

# Example with minimal configuration
resource "kion_billing_source_gcp" "minimal" {
name = "Simple GCP Billing"
service_account_id = 456 # ID of the GCP service account created in Kion
gcp_id = "987654-ZYXWVU-TSRQPO"
billing_start_date = "2024-06"

big_query_export {
gcp_project_id = "billing-exports"
dataset_name = "billing_data"
table_name = "cost_export"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `big_query_export` (Block List, Min: 1, Max: 1) BigQuery export configuration for billing data. (see [below for nested schema](#nestedblock--big_query_export))
- `billing_start_date` (String) The start date for billing data collection in YYYY-MM format.
- `gcp_id` (String) The GCP ID of the billing account (e.g., '012345-678901-ABCDEF').
- `name` (String) The name of the GCP billing source.
- `service_account_id` (Number) The ID of the GCP service account used for authentication.

### Optional

- `account_type_id` (Number) The account type ID for the GCP billing source. Defaults to 15 (Google Cloud).
- `is_reseller` (Boolean) Denotes if the billing account is that of a Parent Reseller Billing Account.
- `use_focus` (Boolean) Use GCP FOCUS view for billing data.
- `use_proprietary` (Boolean) Use the GCP Proprietary Billing Table.

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--big_query_export"></a>
### Nested Schema for `big_query_export`

Required:

- `dataset_name` (String) The name of the BigQuery dataset where the export lives.
- `gcp_project_id` (String) The ID of the GCP project where the BigQuery dataset lives.
- `table_name` (String) The name of the BigQuery table where the export lives.

Optional:

- `focus_view_name` (String) The name of the FOCUS view in BigQuery.
- `table_format` (String) The format of the BigQuery table where the export lives. One of 'auto', 'standard' or 'detailed'.
Loading
Loading