Skip to content

IAmFrench/terraform-aws-billing-export

Repository files navigation

Amazon Web Services (AWS) Billing export Terraform Module

Terraform module witch creates billing export on AWS.

FOCUS v1.0 billing export for AWS now available!

This module will create S3 bucket for AWS billing exports.

What is FOCUS™?

The FinOps Cost and Usage Specification (FOCUS™) is an open-source specification that defines clear requirements for cloud vendors to produce consistent cost and usage datasets.

Supported by the FinOps Foundation, FOCUS™ aims to reduce complexity for FinOps Practitioners so they can drive data-driven decision-making and maximize the business value of cloud, while making their skills more transferable across clouds, tools, and organizations.

Learn more about FOCUS in this FinOps Foundation Insights article.

Usage

# FOCUS v1.0 AWS billing export with the creation of the S3 bucket
module "aws_billing_export" {
  source  = "IAmFrench/billing-export/aws"

  # Version of this module, see release on GitHub: https://github.com/IAmFrench/terraform-aws-billing-export/releases
  version = "1.0.4"
  
  # Name of the S3 bucket to create exports in
  s3_bucket_name   = "finops-exports-1a2b3c4d"
  # Type of the export
  export_type      = "FOCUS"
  # Version of the export
  export_version   = "1.0"
  # Name of the export
  export_name      = "focus-v1-0-export"
  # Prefix of the export
  export_s3_prefix = "focus/v1.0/1234556789"
}
# FOCUS v1.0 AWS billing export with an existing S3 bucket
module "aws_billing_export" {
  source  = "IAmFrench/billing-export/aws"

  # Version of this module, see release on GitHub: https://github.com/IAmFrench/terraform-aws-billing-export/releases
  version = "1.0.4"
  
  # Name of the S3 bucket to create exports in
  s3_bucket_name   = data.aws_s3_bucket.export.id
  # Should this module create the S3 bucket with associated policy?
  create_s3_bucket = false
  # Type of the export
  export_type      = "FOCUS"
  # Version of the export
  export_version   = "1.0"
  # Name of the export
  export_name      = "focus-v1-0-export"
  # Prefix of the export
  export_s3_prefix = "focus/v1.0/1234556789"
}

Roadmap

Common errors

Requirements

Name Version
terraform >= 1.1.0
aws >= 5.47.0

Providers

Name Version
aws >= 5.47.0

Modules

No modules.

Resources

Name Type
aws_bcmdataexports_export.focus resource
aws_s3_bucket.export resource
aws_s3_bucket_policy.allow_data_export resource
aws_caller_identity.current data source
aws_iam_policy_document.allow_data_export data source
aws_s3_bucket.export data source

Inputs

Name Description Type Default Required
create_s3_bucket Option to create or not the S3 bucket for the billing export.
If set to false, this module will not create the S3 bucket.
Therefore please check that bucket policies are sets to allow AWS export services to write files in it.
More info: https://docs.aws.amazon.com/cur/latest/userguide/dataexports-s3-bucket.html

E.g.: true, false
bool true no
export_name Name of the billing export.
Validation: Export name must be unique, not include spaces, and contain only alphanumeric and characters ! - _ . * ' ( )
E.g.: focus-v1-0-preview
string n/a yes
export_s3_prefix Prefix of the billing export.
E.g.: focus/123456789 with 123456789 being the account id
string "" no
export_type Version of the billing export.
Valid values: FOCUS or CUR
E.g.: FOCUS or CUR
string n/a yes
export_version Version of the billing export. Should be use with export_type.
Valid values are:
- 1.0 and 1.0-preview for FOCUS
- legacy or 2.0 for CUR
E.g.: 1.0, 1.0-preview, legacy, 2.0
string n/a yes
s3_bucket_name Name of the S3 bucket to be created
E.g.: finops-focus-export-a1b2c3d4
string n/a yes
tags Tags to apply to all created resources.
E.g.:
{
createdBy = "Terraform"
}
map(string) {} no

Outputs

Name Description
export_arn ARN of the export
s3_arn ARN of the export bucket