Skip to content

Commit

Permalink
feat: Add forecasted e2e test (Azure#3059)
Browse files Browse the repository at this point in the history
## Description

Closes Azure#2423

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| 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

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] 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

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
segraef authored Aug 20, 2024
1 parent be99668 commit 04b5efb
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 6 deletions.
73 changes: 69 additions & 4 deletions avm/res/consumption/budget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<version>`.
- [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_

Expand Down Expand Up @@ -89,7 +90,71 @@ module budget 'br/public:avm/res/consumption/budget:<version>' = {
</details>
<p>

### 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`.


<details>

<summary>via Bicep module</summary>

```bicep
module budget 'br/public:avm/res/consumption/budget:<version>' = {
name: 'budgetDeployment'
params: {
// Required parameters
amount: 500
name: 'cbfcst001'
// Non-required parameters
contactEmails: [
'[email protected]'
]
location: '<location>'
thresholdType: 'Forecasted'
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```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": [
"[email protected]"
]
},
"location": {
"value": "<location>"
},
"thresholdType": {
"value": "Forecasted"
}
}
}
```

</details>
<p>

### Example 3: _Using large parameter set_

This instance deploys the module with most of its features enabled.

Expand Down Expand Up @@ -175,7 +240,7 @@ module budget 'br/public:avm/res/consumption/budget:<version>' = {
</details>
<p>

### 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.

Expand Down
4 changes: 2 additions & 2 deletions avm/res/consumption/budget/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
37 changes: 37 additions & 0 deletions avm/res/consumption/budget/tests/e2e/forecasted/main.test.bicep
Original file line number Diff line number Diff line change
@@ -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: [
'[email protected]'
]
thresholdType: 'Forecasted'
}
}
]

0 comments on commit 04b5efb

Please sign in to comment.