Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
r/burn_alert: Add support for budget rate burn alerts (#391)
## Short description of the changes This PR adds support for budget rate burn alerts to the burn alert resource. ## How to verify that this has the expected result Pre-requisites: - You'll need Go 1.20 and the latest Terraform installed. - You'll need a team in Honeycomb to test against. - You'll need a dataset, derived column, and SLO for that team. - You'll need an API key for that team. #### Setup: 1. Create a new directory called `providers` somewhere you can easily access (but not inside the same folder as your Terraform config). 1. Build the provider by checking out this branch and running `make build` 1. Move the executable created to the `providers` directory you created earlier. ``` mv terraform-provider-honeycombio /PATH/TO/YOUR/DIRECTORY/providers ``` 1. Add the following to your ~/.terraformrc file: ``` provider_installation { # Use /PATH/TO/YOUR/DIRECTORY/providers/terraform-provider-honeycombio # as an overridden package directory for the honeycombio/honeycombio provider. # This disables the version and checksum verifications for this provider and # forces Terraform to look for the null provider plugin in the given directory. #dev_overrides { # "honeycombio/honeycombio" = "/PATH/TO/YOUR/DIRECTORY/providers" #} # For all other providers, install them directly from their origin provider # registries as normal. If you omit this, Terraform will _only_ use # the dev_overrides block, and so no other providers will be available. direct {} } ``` 1. Create another new directory (all Terraform commands will be run in this directory) 1. [Download and save this file](https://github.com/honeycombio/terraform-provider-honeycombio/files/13367011/budget-rate-burn-alerts-config.tf.txt) as `main.tf` in your new directory. You'll be modifying it in the steps below. 1. Set the following environment variables: ``` export HONEYCOMB_API_KEY=YOUR_API_KEY_HERE export TF_VAR_dataset=YOUR_DATASET_SLUG_HERE export TF_VAR_slo_id=YOUR_SLO_ID_HERE ``` 1. Run `terraform init`. #### Provision resources for r/burn_alert: 1. Run `terraform apply`. This should succeed and if you check in the UI, you should see the burn alerts you just created. 1. Run `terraform plan`. There should be no changes. #### Check that upgrading provider version doesn't break anything: 1. Update your provider version to local build of this branch by editing your ~/.terraformrc file and remove the comments in front of the dev_overrides block ``` dev_overrides { "honeycombio/honeycombio" = "/PATH/TO/YOUR/DIRECTORY/providers" } ``` 1. Run `terraform plan`. This time you should see a yellow warning block telling you that development overrides are in place. It should look like this: <img width="1293" alt="Screenshot 2023-11-13 at 3 34 46 PM" src="https://github.com/honeycombio/terraform-provider-honeycombio/assets/12189856/7a1d4383-2581-493d-88ab-923476baafc2"> #### Check that validation works: 1. Uncomment the 2nd and 3rd burn alerts in your config. 1. Run `terraform apply`. This should succeed and if you check in the UI, you should see the 2 new burn alerts you just created. 1. Try updating each of your burn alerts to be invalid. Examples include: - Invalid `alert_type` - Exhaustion time alert without `exhaustion_minutes` specified - Exhaustion time alert with `exhaustion_minutes` < 0 - Exhaustion time alert with budget rate fields specified - Budget rate alert without budget rate fields specified - Budget rate alert with `budget_rate_window_minutes` < 60 or > the SLO's time period - Budget rate alert with `budget_rate_decrease_percent` < 0.0001 or > 100 - Budget rate alert with `budget_rate_decrease_percent` with more than 4 non-zero digits past the decimal - Budget rate alert with `exhaustion_minutes` specified 1. Run `terraform apply`. This should fail and you should see descriptive errors about what attributes have been misconfigured. 1. Undo any changes to your config before moving on #### Check that updating burn alerts works: 1. Update each of your burn alerts by changing any valid combo of `alert_type`, `exhaustion_minutes`, `budget_rate_window_minutes`, or `budget_rate_decrease_percent`. Examples of useful scenarios to test out: - Exhaustion time alert to a budget rate alert - Budget rate alert to an exhaustion time alert - Budget rate burn alert to an exhaustion time burn alert **without** specifying the `alert_type` - Exhaustion time alert to have `exhaustion_minutes` = 0 1. Run `terraform apply`. The output should show the changes you made in the config. After confirming, you should see these changes reflected in the UI. 1. Run `terraform plan`. Your plan should show no changes. #### Check that destroy works 1. Run `terraform destroy`. This should succeed. You should see these changes reflected in the UI. #### Check that a fresh create works 1. Run `terraform apply`. This should succeed. You should see these changes reflected in the UI. ## Related links - [API documentation](https://docs.honeycomb.io/api/tag/Burn-Alerts)
- Loading branch information