Skip to content

Commit

Permalink
PC-11815 add budget adjustments terraform support
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaceg committed Feb 26, 2024
1 parent 470154f commit 0dacb04
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NAMESPACE=nobl9
NAME=nobl9
BIN_DIR=./bin
BINARY=$(BIN_DIR)/terraform-provider-$(NAME)
VERSION=0.23.0
VERSION=0.24.0
BUILD_FLAGS="-X github.com/nobl9/terraform-provider-nobl9/nobl9.Version=$(VERSION)"
OS_ARCH?=linux_amd64

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
version = "0.23.0"
version = "0.24.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
version = "0.23.0"
version = "0.24.0"
}
}
}
Expand Down
96 changes: 96 additions & 0 deletions docs/resources/budget_adjustment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
---
page_title: "nobl9_budget_adjustment Resource - terraform-provider-nobl9"
description: |-
Budget adjustment configuration documentation https://docs.nobl9.com/yaml-guide#budget-adjustment
---

# nobl9_budget_adjustment (Resource)

An **Budget Adjustment** some description

For more details, refer to the [Budget adjustment configuration documentation](https://docs.nobl9.com/yaml-guide#budget-adjustment).

## Example Usage

Here's an example of Budget Adjustment resource configuration:

```terraform
resource "nobl9_budget_adjustment" "single-budget-adjustment-event" {
name = "single-budget-adjustment-event"
display_name = "Single Budget Adjustment Event"
first_event_start = "2022-01-01T00:00:00Z"
duration = "1h"
description = "Single budget adjustment event"
filters {
slos {
slo {
name = "my-slo"
project = "default"
}
}
}
}
resource "nobl9_budget_adjustment" "recurring-budget-adjustment-event" {
name = "recurring-budget-adjustment-event"
display_name = "Recurring Budget Adjustment Event"
first_event_start = "2022-01-01T16:00:00Z"
duration = "1h"
rrule = "FREQ=WEEKLY"
description = "Recurring budget adjustment event"
filters {
slos {
slo {
name = "my-slo"
project = "default"
}
}
}
}
```

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

### Required

- `duration` (String) The duration of the budget adjustment event. The expected value is a string in time duration string format. Duration must be defined with 1 minute precision.Example: `1h10m`
- `first_event_start` (String) The time of the first event start. The expected value is a string with date in RFC3339 format. Example: `2022-12-31T00:00:00Z`
- `name` (String) Unique name of the resource, must conform to the naming convention from [DNS RFC1123](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).

### Optional

- `description` (String) Optional description of the resource. Here, you can add details about who is responsible for the integration (team/owner) or the purpose of creating it.
- `display_name` (String) User-friendly display name of the resource.
- `filters` (Block Set) Filters are used to select SLOs for the budget adjustment event. (see [below for nested schema](#nestedblock--filters))
- `rrule` (String) The recurrence rule for the budget adjustment event. The expected value is a string in RRULE format. Example: `FREQ=MONTHLY;BYMONTHDAY=1`

### Read-Only

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

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

Required:

- `slos` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--filters--slos))

<a id="nestedblock--filters--slos"></a>
### Nested Schema for `filters.slos`

Required:

- `slo` (Block List, Min: 1) SLO where budget adjustment event will be applied. (see [below for nested schema](#nestedblock--filters--slos--slo))

<a id="nestedblock--filters--slos--slo"></a>
### Nested Schema for `filters.slos.slo`

Required:

- `name` (String) Unique name of the resource, must conform to the naming convention from [DNS RFC1123](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).
- `project` (String) Name of the Nobl9 project the resource sits in, must conform to the naming convention from [DNS RFC1123](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).

## Useful Links

[Budget Adjustment configuration | Nobl9 Documentation](https://docs.nobl9.com/yaml-guide#budget-adjustment)
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
version = "0.23.0"
version = "0.24.0"
}
}
}
Expand Down
32 changes: 32 additions & 0 deletions examples/resources/nobl9_budget_adjustment/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "nobl9_budget_adjustment" "single-budget-adjustment-event" {
name = "single-budget-adjustment-event"
display_name = "Single Budget Adjustment Event"
first_event_start = "2022-01-01T00:00:00Z"
duration = "1h"
description = "Single budget adjustment event"
filters {
slos {
slo {
name = "my-slo"
project = "default"
}
}
}
}

resource "nobl9_budget_adjustment" "recurring-budget-adjustment-event" {
name = "recurring-budget-adjustment-event"
display_name = "Recurring Budget Adjustment Event"
first_event_start = "2022-01-01T16:00:00Z"
duration = "1h"
rrule = "FREQ=WEEKLY"
description = "Recurring budget adjustment event"
filters {
slos {
slo {
name = "my-slo"
project = "default"
}
}
}
}
12 changes: 7 additions & 5 deletions nobl9/resource_budgetadjustment.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ func schemaBudgetAdjustment() map[string]*schema.Schema {
"Example: `FREQ=MONTHLY;BYMONTHDAY=1`",
},
"filters": {
Type: schema.TypeSet,
Optional: true,
Type: schema.TypeSet,
Optional: true,
Description: "Filters are used to select SLOs for the budget adjustment event.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"slos": {
Expand All @@ -71,9 +72,10 @@ func schemaBudgetAdjustment() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"slo": {
Type: schema.TypeList,
MinItems: 1,
Required: true,
Type: schema.TypeList,
MinItems: 1,
Required: true,
Description: "SLO where budget adjustment event will be applied.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": schemaName(),
Expand Down
18 changes: 12 additions & 6 deletions nobl9/resource_budgetadjustment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,35 @@ resource "nobl9_budget_adjustment" "%s" {
}

func testBudgetAdjustmentRecurringEvent(name string) string {
return fmt.Sprintf(`
resource "nobl9_budget_adjustment" "%s" {
return fmt.Sprintf(`resource "nobl9_budget_adjustment" "%s" {
name = "%s"
first_event_start = "2022-01-01T00:00:00Z"
duration = "1h"
rrule = "FREQ=MONTHLY;BYMONTHDAY=1"
filters {
slos {
slo {
name = "ratio-slo"
project = "default"
name = "cloudwatch-ratio-slo"
project = "cloudwatch"
}
slo {
name = "cloudwatch-ratio-slo2"
project = "cloudwatch"
}
}
}
}
`, name, name)
}`, name, name)
}

func testBudgetAdjustmentRecurringEventMultipleSlo(name string) string {
return fmt.Sprintf(`
resource "nobl9_budget_adjustment" "%s" {
name = "%s"
display_name = "Recurring budget adjustment for the first day of the month."
first_event_start = "2022-01-01T00:00:00Z"
description = "Recurring budget adjustment for the first day of the month."
duration = "1h"
rrule = "FREQ=MONTHLY;BYMONTHDAY=1"
filters {
slos {
slo {
Expand Down
23 changes: 23 additions & 0 deletions templates/resources/budget_adjustment.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
description: |-
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
---

# {{.Name}} ({{.Type}})

An **Budget Adjustment** some description

For more details, refer to the {{ .Description | trimspace }}.

## Example Usage

Here's an example of Budget Adjustment resource configuration:

{{ tffile (printf "examples/resources/%s/resource.tf" .Name)}}

{{ .SchemaMarkdown | trimspace }}

## Useful Links

[Budget Adjustment configuration | Nobl9 Documentation](https://docs.nobl9.com/yaml-guide#budget-adjustment)

0 comments on commit 0dacb04

Please sign in to comment.