From 04b5efb07b4c4b6e3992ca6f85ddf5910471920a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Gr=C3=A4f?= Date: Tue, 20 Aug 2024 16:54:10 +1000 Subject: [PATCH] feat: Add forecasted e2e test (#3059) ## Description Closes https://github.com/Azure/bicep-registry-modules/issues/2423 ## Pipeline Reference | Pipeline | | -------- | | [![avm.res.consumption.budget](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.consumption.budget.yml/badge.svg?branch=users%2Fsegraef%2F2442)](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.consumption.budget.yml) | ## Type of Change - [ ] Update to CI Environment or utilities (Non-module affecting changes) - [x] Azure Verified Module updates: - [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [ ] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] Breaking changes and I have bumped the MAJOR version in `version.json`. - [x] Update to documentation ## Checklist - [x] I'm sure there are no other open Pull Requests for the same update/change - [x] I have run `Set-AVMModule` locally to generate the supporting module files. - [x] My corresponding pipelines / checks run clean and green without any errors or warnings --- avm/res/consumption/budget/README.md | 73 ++++++++++++++++++- avm/res/consumption/budget/main.json | 4 +- .../tests/e2e/forecasted/main.test.bicep | 37 ++++++++++ 3 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 avm/res/consumption/budget/tests/e2e/forecasted/main.test.bicep diff --git a/avm/res/consumption/budget/README.md b/avm/res/consumption/budget/README.md index 4b4f942775..927392c5f1 100644 --- a/avm/res/consumption/budget/README.md +++ b/avm/res/consumption/budget/README.md @@ -26,8 +26,9 @@ The following section provides usage examples for the module, which were used to >**Note**: To reference the module, please use the following syntax `br/public:avm/res/consumption/budget:`. - [Using only defaults](#example-1-using-only-defaults) -- [Using large parameter set](#example-2-using-large-parameter-set) -- [WAF-aligned](#example-3-waf-aligned) +- [Using `thresholdType` `Forecasted`](#example-2-using-thresholdtype-forecasted) +- [Using large parameter set](#example-3-using-large-parameter-set) +- [WAF-aligned](#example-4-waf-aligned) ### Example 1: _Using only defaults_ @@ -89,7 +90,71 @@ module budget 'br/public:avm/res/consumption/budget:' = {

-### Example 2: _Using large parameter set_ +### Example 2: _Using `thresholdType` `Forecasted`_ + +This instance deploys the module with the minimum set of required parameters and `thresholdType` `Forecasted`. + + +

+ +via Bicep module + +```bicep +module budget 'br/public:avm/res/consumption/budget:' = { + name: 'budgetDeployment' + params: { + // Required parameters + amount: 500 + name: 'cbfcst001' + // Non-required parameters + contactEmails: [ + 'dummy@contoso.com' + ] + location: '' + thresholdType: 'Forecasted' + } +} +``` + +
+

+ +

+ +via JSON Parameter file + +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + // Required parameters + "amount": { + "value": 500 + }, + "name": { + "value": "cbfcst001" + }, + // Non-required parameters + "contactEmails": { + "value": [ + "dummy@contoso.com" + ] + }, + "location": { + "value": "" + }, + "thresholdType": { + "value": "Forecasted" + } + } +} +``` + +
+

+ +### Example 3: _Using large parameter set_ This instance deploys the module with most of its features enabled. @@ -175,7 +240,7 @@ module budget 'br/public:avm/res/consumption/budget:' = {

-### Example 3: _WAF-aligned_ +### Example 4: _WAF-aligned_ This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework. diff --git a/avm/res/consumption/budget/main.json b/avm/res/consumption/budget/main.json index d51817dbd2..b68ced8a2d 100644 --- a/avm/res/consumption/budget/main.json +++ b/avm/res/consumption/budget/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.28.1.47646", - "templateHash": "13231547958069431465" + "version": "0.29.47.4906", + "templateHash": "9899827298268482806" }, "name": "Consumption Budgets", "description": "This module deploys a Consumption Budget for Subscriptions.", diff --git a/avm/res/consumption/budget/tests/e2e/forecasted/main.test.bicep b/avm/res/consumption/budget/tests/e2e/forecasted/main.test.bicep new file mode 100644 index 0000000000..91112be1f4 --- /dev/null +++ b/avm/res/consumption/budget/tests/e2e/forecasted/main.test.bicep @@ -0,0 +1,37 @@ +targetScope = 'subscription' + +metadata name = 'Using `thresholdType` `Forecasted`' +metadata description = 'This instance deploys the module with the minimum set of required parameters and `thresholdType` `Forecasted`.' + +// ========== // +// Parameters // +// ========== // + +@description('Optional. The location to deploy resources to.') +param resourceLocation string = deployment().location + +@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.') +param serviceShort string = 'cbfcst' + +@description('Optional. A token to inject into the name of each resource.') +param namePrefix string = '#_namePrefix_#' + +// ============== // +// Test Execution // +// ============== // + +@batchSize(1) +module testDeployment '../../../main.bicep' = [ + for iteration in ['init', 'idem']: { + name: '${uniqueString(deployment().name)}-test-${serviceShort}-${iteration}' + params: { + name: '${namePrefix}${serviceShort}001' + location: resourceLocation + amount: 500 + contactEmails: [ + 'dummy@contoso.com' + ] + thresholdType: 'Forecasted' + } + } +]