Skip to content

Commit 9807122

Browse files
authored
Moved bicepparam file support to stable Azure#2682 (Azure#2692)
1 parent 128b553 commit 9807122

File tree

7 files changed

+61
-68
lines changed

7 files changed

+61
-68
lines changed

docs/CHANGELOG-v1.md

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ What's changed since v1.33.2:
5555
- Added a selector for classic profiles `Azure.FrontDoor.IsClassic`.
5656
- Updated rule set to `2024_03`.
5757
- General improvements:
58+
- Moved `.bicepparam` file support to stable by @BernieWhite.
59+
[#2682](https://github.com/Azure/PSRule.Rules.Azure/issues/2682)
60+
- Bicep param files are now automatically expanded when found.
61+
- To disable expansion, set the configuration option `AZURE_BICEP_PARAMS_FILE_EXPANSION` to `false`.
5862
- Documentation and metadata improvements by @BernieWhite.
5963
[#1772](https://github.com/Azure/PSRule.Rules.Azure/issues/1772)
6064
[#2570](https://github.com/Azure/PSRule.Rules.Azure/issues/2570)

docs/hooks/shortcodes.py

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def _badge_for_configuration(text: str, page: Page, files: Files) -> str:
110110
if config_type == "rule":
111111
path = f"../../setup/configuring-rules.md#{config_value.lower()}"
112112

113+
if config_type == "expand":
114+
path = f"../../setup/configuring-expansion.md#{config_value.lower()}"
115+
113116
icon = "octicons-gear-24"
114117
href = path
115118
text = config_value

docs/quickstarts/test-bicep-with-github.md

+38-29
Original file line numberDiff line numberDiff line change
@@ -114,33 +114,40 @@ Options in this file will automatically be detected by other PSRule commands and
114114
2. In the root of your repository, create a new file called `ps-rule.yaml`.
115115
3. Update the file with the following contents and save.
116116

117-
```yaml title="ps-rule.yaml"
118-
#
119-
# PSRule configuration
120-
#
121-
122-
# Please see the documentation for all configuration options:
123-
# https://aka.ms/ps-rule-azure/options
124-
125-
# Require a minimum version of PSRule for Azure.
126-
requires:
127-
PSRule.Rules.Azure: '>=1.29.0'
128-
129-
# Automatically use rules for Azure.
130-
include:
131-
module:
132-
- PSRule.Rules.Azure
133-
134-
# Ignore all files except .bicepparam files.
135-
input:
136-
pathIgnore:
137-
- '**'
138-
- '!**/*.bicepparam'
139-
140-
# Enable expansion of Azure .bicepparam files.
141-
configuration:
142-
AZURE_BICEP_PARAMS_FILE_EXPANSION: true
143-
```
117+
```yaml title="ps-rule.yaml"
118+
#
119+
# PSRule configuration
120+
#
121+
122+
# Please see the documentation for all configuration options:
123+
# https://aka.ms/ps-rule-azure/options
124+
125+
# Require a minimum version of PSRule for Azure.
126+
requires:
127+
PSRule.Rules.Azure: '>=1.34.0' # (1)
128+
129+
# Automatically use rules for Azure.
130+
include:
131+
module:
132+
- PSRule.Rules.Azure # (2)
133+
134+
# Ignore all files except .bicepparam files.
135+
input:
136+
pathIgnore:
137+
- '**' # (3)
138+
- '!**/*.bicepparam' # (4)
139+
```
140+
141+
<div class="result" markdown>
142+
1. Set the minimum required version of PSRule for Azure to use.
143+
This does not install the required version, but will fail if the version is not available.
144+
Across a team and CI/CD pipeline, this can help ensure a consistent version of PSRule is used.
145+
2. Automatically use the rules in PSRule for Azure for each run.
146+
3. Ignore all files by default.
147+
PSRule will not try to analyze ignored files.
148+
4. Add an exception for `.bicepparam` files.
149+
150+
</div>
144151

145152
[7]: https://code.visualstudio.com/docs/sourcecontrol/overview#_branches-and-tags
146153

@@ -183,7 +190,7 @@ jobs:
183190
steps:
184191
185192
- name: Checkout
186-
uses: actions/checkout@v3
193+
uses: actions/checkout@v4
187194
188195
- name: Run PSRule analysis
189196
uses: microsoft/[email protected] # (1)
@@ -193,11 +200,13 @@ jobs:
193200

194201
<div class="result" markdown>
195202
1. Reference the PSRule action.
196-
You can find the latest version of the action on the [GitHub Marketplace](https://github.com/marketplace/actions/psrule).
203+
You can find the latest version of the action on the [GitHub Marketplace][14].
197204
2. Automatically download and use PSRule for Azure during analysis.
198205

199206
</div>
200207

208+
[14]: https://github.com/marketplace/actions/psrule
209+
201210
## Commit and push changes
202211

203212
1. Commit and push the changes to your repository.

docs/setup/configuring-expansion.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ configuration:
8282

8383
### Bicep parameter expansion
8484

85-
<!-- module:version v1.27.0 -->
85+
<!-- module:version v1.34.0 -->
8686

8787
This configuration option determines if Azure Bicep parameter files (`.bicepparam`) are expanded.
88-
Currently while this is an experimental feature this is not enabled by default.
88+
By default, Bicep parameter files will be automatically expanded.
8989

9090
Bicep files are expanded when PSRule cmdlets with the `-Format File` parameter are used.
9191

@@ -101,15 +101,15 @@ Default:
101101
```yaml title='ps-rule.yaml'
102102
# YAML: The default AZURE_BICEP_PARAMS_FILE_EXPANSION configuration option
103103
configuration:
104-
AZURE_BICEP_PARAMS_FILE_EXPANSION: false
104+
AZURE_BICEP_PARAMS_FILE_EXPANSION: true
105105
```
106106

107107
Example:
108108

109109
```yaml title='ps-rule.yaml'
110110
# YAML: Set the AZURE_BICEP_PARAMS_FILE_EXPANSION configuration option to enable expansion
111111
configuration:
112-
AZURE_BICEP_PARAMS_FILE_EXPANSION: true
112+
AZURE_BICEP_PARAMS_FILE_EXPANSION: false
113113
```
114114

115115
### Bicep compilation timeout

docs/using-bicep.md

+10-30
Original file line numberDiff line numberDiff line change
@@ -193,51 +193,32 @@ This option will discover Bicep files from parameter metadata.
193193

194194
### Using Bicep parameter files
195195

196-
:octicons-beaker-24:{ .experimental } Experimental · :octicons-milestone-24: v1.27.0
196+
<!-- module:version v1.34.0 -->
197197

198198
You can use `.bicepparam` files to reference your Bicep modules as a method for providing parameters.
199199
Using the Bicep parameter file format, allows you to get many of the benefits of the Bicep language.
200200

201201
For example:
202202

203203
```bicepparam
204-
using 'template.bicep'
204+
using 'main.bicep'
205205
206206
param storageAccountName = 'bicepstorage001'
207207
param tags = {
208208
env: 'test'
209209
}
210210
```
211211

212-
Presently, to use this feature you must:
213-
214-
1. Enable the experimental feature in `bicepconfig.json`.
215-
2. Enable expansion of Bicep parameter files in `ps-rule.yaml`.
216-
217-
For example:
218-
219-
```json title="bicepconfig.json"
220-
{
221-
"experimentalFeaturesEnabled": {
222-
"paramsFiles": true
223-
}
224-
}
225-
```
226-
227-
```yaml title="ps-rule.yaml"
228-
configuration:
229-
AZURE_BICEP_PARAMS_FILE_EXPANSION: true
230-
```
231-
232-
!!! Experimental "Experimental - [Learn more][13]"
233-
Bicep parameter files are a work in progress.
234-
This feature will be transitioned to stable after the Bicep CLI support is finalized.
235-
236212
!!! Learn
237213
To learn more about Bicep parameter files see [Create parameters files for Bicep deployment][16].
238214

239-
[13]: versioning.md#experimental-features
215+
!!! Note
216+
To use Bicep parameter files you must use a minimum of Bicep CLI version **0.18.4**.
217+
You can configure PSRule to check for the minimum Bicep version.
218+
See [configuring minimum version][10] for information on how to enable this check.
219+
240220
[16]: https://learn.microsoft.com/azure/azure-resource-manager/bicep/parameter-files?tabs=Bicep
221+
[10]: setup/setup-bicep.md#configuring-minimum-version
241222

242223
## Restoring modules from a private registry
243224

@@ -266,7 +247,6 @@ To configure your registry see [Make your container registry content publicly av
266247

267248
[15]: https://learn.microsoft.com/azure/azure-resource-manager/bicep/private-module-registry
268249
[14]: https://learn.microsoft.com/azure/container-registry/anonymous-pull-access
269-
[10]: setup/setup-bicep.md#configuring-minimum-version
270250

271251
### Configure `bicepconfig.json`
272252

@@ -296,11 +276,11 @@ Use the following credential type based on your environment as the first value o
296276
The `bicepconfig.json` configures the Bicep CLI.
297277
You should commit this file into a repository along with your Bicep code.
298278

299-
[9]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview
279+
[9]: https://learn.microsoft.com/entra/identity/managed-identities-azure-resources/overview
300280

301281
### Granting access to a private registry
302282

303-
To access a private registry use an Azure AD identity which has been granted permissions to pull Bicep modules.
283+
To access a private registry use an Entra ID identity which has been granted permissions to pull Bicep modules.
304284
When using `Environment` credential type, see [create a service principal that can access resources][11] to create the identity.
305285
If you are using the `ManagedIdentity` credential type, an identity is created for when you [configure the managed identity][9].
306286

src/PSRule.Rules.Azure/rules/Config.Rule.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ spec:
3333
AZURE_BICEP_FILE_EXPANSION: false
3434

3535
# Enable expansion from .bicepparam files.
36-
AZURE_BICEP_PARAMS_FILE_EXPANSION: false
36+
AZURE_BICEP_PARAMS_FILE_EXPANSION: true
3737

3838
# Check for a minimum version of the Bicep CLI.
3939
AZURE_BICEP_MINIMUM_VERSION: '0.4.451'

tests/Bicep/Bicep.Tests.ps1

+1-4
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ Describe 'Bicep' -Tag 'Bicep' {
130130
$sourceFile = Join-Path -Path $here -ChildPath 'template.bicepparam';
131131

132132
# Expand source files
133-
$option = @{
134-
'Configuration.AZURE_BICEP_PARAMS_FILE_EXPANSION' = $True
135-
}
136-
$result = @(Invoke-PSRule @invokeParams -InputPath $sourceFile -Format File -Option $option);
133+
$result = @(Invoke-PSRule @invokeParams -InputPath $sourceFile -Format File);
137134
$result.Length | Should -Be 1;
138135
$resource = $result | Where-Object { $_.TargetType -eq 'Microsoft.Storage/storageAccounts' };
139136
$resource | Should -Not -BeNullOrEmpty;

0 commit comments

Comments
 (0)