generated from geekcell/terraform-aws-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
48 lines (43 loc) · 1.88 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* # Terraform AWS Budgets
*
* This Terraform module provides a preconfigured solution for setting up
* AWS Budgets for your AWS account. Our team has years of experience working
* with AWS Budgets, and we are sharing our knowledge with you through this
* module. With this module, you can quickly and easily set up budgets that
* align with your organization's goals and get alerts when your usage exceeds
* your specified limits. By using this module, you can save time and avoid
* common mistakes when setting up AWS Budgets.
*
* Not only is this module easy to configure, but it also encapsulates
* everything you need in one place. You can simply use the module and be
* confident that everything has been set up correctly and efficiently.
*
* This makes it an excellent choice for organizations of any size looking
* to effectively manage their AWS costs.
*/
resource "aws_budgets_budget" "main" {
for_each = { for i, budget in var.budgets : budget.name => budget }
name = format("%s-%s", var.name, each.value.name)
budget_type = each.value.budget_type
limit_amount = each.value.limit_amount
limit_unit = each.value.limit_unit
time_unit = each.value.time_unit
account_id = data.aws_caller_identity.current.account_id
time_period_start = each.value.time_period_start
time_period_end = each.value.time_period_end
dynamic "cost_filter" {
for_each = each.value.cost_filter == null ? {} : each.value.cost_filter
content {
name = cost_filter.key
values = cost_filter.value
}
}
notification {
comparison_operator = each.value.notification.comparison_operator
notification_type = each.value.notification.notification_type
subscriber_email_addresses = var.recipients
threshold = each.value.notification.threshold
threshold_type = each.value.notification.threshold_type
}
}