An open API service indexing awesome lists of open source software.

https://github.com/jameswoolfenden/terraform-aws-budget

Creates budgets for AWS Usage
https://github.com/jameswoolfenden/terraform-aws-budget

aws budget module terraform

Last synced: 12 months ago
JSON representation

Creates budgets for AWS Usage

Awesome Lists containing this project

README

          

# terraform-aws-budget

[![Build Status](https://github.com/JamesWoolfenden/terraform-aws-budget/workflows/Verify%20and%20Bump/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-aws-budget)
[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-aws-budget.svg)](https://github.com/JamesWoolfenden/terraform-aws-budget/releases/latest)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/JamesWoolfenden/terraform-aws-budget.svg?label=latest)](https://github.com/JamesWoolfenden/terraform-aws-budget/releases/latest)
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.14.0-blue.svg)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/JamesWoolfenden/terraform-aws-budget/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-aws-budget&benchmark=CIS+AWS+V1.2)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-aws-budget/general)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-aws-budget&benchmark=INFRASTRUCTURE+SECURITY)

Terraform module - creates a Budget and a Budget for half as much.

---

It's 100% Open Source and licensed under the [APACHE2](LICENSE).

## Usage

These are just basic examples, your budget rules should be much more sophisticated.

Include this repository as a module in your existing terraform code:

```terraform
module "budget" {
source = "JamesWoolfenden/budget/aws"
version = "0.3.32"
limit = var.limit
time_period_start = var.time_period_start
budget = var.budget
notification = var.notification
}
```

The module reference uses 2 objects, budget and notification, from the example data. This module implements billing alerts on your AWS account,
the provided variables are in **examplea.auto.tfvars**:

```HCL
budget={
name = "budget-ec2-monthly"
budget_type = "COST"
time_unit = "MONTHLY"
limit_unit = "Pounds"
}
notification={
comparison_operator = "GREATER_THAN"
threshold = 100
threshold_type = "PERCENTAGE"
notification_type = "FORECASTED"
subscriber_email_addresses = ["test@example.com"]
subscriber_sns_topic_arns = [""]
}
```

The variable limit creates 2 sets of alerts one at its setting and another at half.
Additional users or groups can added to _subscriber_email_addresses_.

## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_budgets_budget.budget](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/budgets_budget) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [budget](#input\_budget) | Basic Budget Properties | `map(any)` |

{
"budget_type": "COST",
"limit_unit": "USD",
"name": "budget-ec2-monthly",
"time_unit": "MONTHLY"
}
| no |
| [cost\_filters](#input\_cost\_filters) | The Budget filters to use |
list(object({
name = string
values = set(string)
}))
| `[]` | no |
| [half\_budget\_enabled](#input\_half\_budget\_enabled) | Whether to enable or disable the half budget alert | `bool` | `true` | no |
| [limit](#input\_limit) | Budget alarm limit | `number` | n/a | yes |
| [notification](#input\_notification) | Budget notification properties |
object({
comparison_operator = string
threshold = number
threshold_type = string
notification_type = string
subscriber_email_addresses = set(any)
subscriber_sns_topic_arns = set(any)
})
| n/a | yes |
| [time\_period\_start](#input\_time\_period\_start) | Time to start | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| [budget](#output\_budget) | n/a |
| [half\_budget](#output\_half\_budget) | n/a |

## Policy

The Terraform resource required is:

```golang
resource "aws_iam_policy" "terraform_pike" {
name_prefix = "terraform_pike"
path = "/"
description = "Pike Autogenerated policy from IAC"

policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"budgets:ModifyBudget",
"budgets:ViewBudget"
],
"Resource": "*"
}
]
})
}

```

## Related Projects

Check out these related projects.

- [terraform-aws-s3](https://github.com/jameswoolfenden/terraform-aws-s3) - S3 buckets

## Help

**Got a question?**

File a GitHub [issue](https://github.com/JamesWoolfenden/terraform-aws-budget/issues).

## Contributing

### Bug Reports & Feature Requests

Please use the [issue tracker](https://github.com/JamesWoolfenden/terraform-aws-budget/issues) to report any bugs or file feature requests.

## Copyrights

Copyright © 2019-2022 James Woolfenden

## License

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

See [LICENSE](LICENSE) for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

### Contributors

[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]
[James Woolfenden][jameswoolfenden_homepage]

[jameswoolfenden_homepage]: https://github.com/jameswoolfenden
[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150