Skip to content

Commit e6039f0

Browse files
authored
Add bicepparam sample (#41)
1 parent 5f2a43a commit e6039f0

4 files changed

Lines changed: 68 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This repository includes:
3333
This repository shows valid uses of PSRule for Azure, both pass and failure cases.
3434
Inspect the following files for instructions to test PSRule for Azure rules by creating a failure.
3535

36+
- [bicep/deployments/contoso/landing-zones/subscription-1/rg-app-001/dev.bicepparam](bicep/deployments/contoso/landing-zones/subscription-1/rg-app-001/dev.bicepparam)
3637
- [bicep/deployments/contoso/landing-zones/subscription-1/rg-app-002/deploy.bicep](bicep/deployments/contoso/landing-zones/subscription-1/rg-app-002/deploy.bicep)
3738
- [template/deployments/contoso/landing-zones/subscription-1/rg-app-001/sttemplateapp001.parameters.json](template/deployments/contoso/landing-zones/subscription-1/rg-app-001/sttemplateapp001.parameters.json)
3839

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using 'main.bicep'
2+
3+
param environment = 'dev'
4+
param name = 'kv-example-001'
5+
6+
// Key Vault should only accept explicitly allowed traffic through the firewall.
7+
// Set to 'Allow' to fail Azure.KeyVault.Firewall.
8+
param defaultAction = 'Deny'
9+
10+
param workspaceId = '/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-test/providers/microsoft.operationalinsights/workspaces/workspace-001'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
targetScope = 'resourceGroup'
2+
3+
param name string
4+
param location string = resourceGroup().location
5+
6+
@allowed([
7+
'Allow'
8+
'Deny'
9+
])
10+
param defaultAction string = 'Deny'
11+
param environment string
12+
param workspaceId string = ''
13+
14+
resource vault 'Microsoft.KeyVault/vaults@2023-02-01' = {
15+
name: name
16+
location: location
17+
properties: {
18+
sku: {
19+
family: 'A'
20+
name: 'standard'
21+
}
22+
tenantId: tenant().tenantId
23+
enableSoftDelete: true
24+
enablePurgeProtection: true
25+
enableRbacAuthorization: true
26+
networkAcls: {
27+
defaultAction: defaultAction
28+
}
29+
}
30+
tags: {
31+
env: environment
32+
}
33+
}
34+
35+
@sys.description('Configure auditing for Key Vault.')
36+
resource logs 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (!empty(workspaceId)) {
37+
name: 'service'
38+
scope: vault
39+
properties: {
40+
workspaceId: workspaceId
41+
logs: [
42+
{
43+
category: 'AuditEvent'
44+
enabled: true
45+
}
46+
]
47+
}
48+
}

ps-rule.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ output:
3030
input:
3131
pathIgnore:
3232
# Ignore other files in the repository.
33-
- '.vscode/'
34-
- '.github/'
35-
- '*.md'
33+
- '**'
3634

37-
# Exclude modules but not tests.
38-
- 'bicep/modules/**/*.bicep'
35+
# Include deployments.
36+
- '!bicep/deployments/**/*.bicepparam'
37+
- '!bicep/deployments/**/deploy.bicep'
38+
- '!template/**/*.parameters.json'
39+
40+
# Include module tests.
3941
- '!bicep/modules/**/*.tests.bicep'
4042

4143
configuration:
@@ -44,6 +46,7 @@ configuration:
4446

4547
# Enable automatic expansion of Azure Bicep source files.
4648
AZURE_BICEP_FILE_EXPANSION: true
49+
AZURE_BICEP_PARAMS_FILE_EXPANSION: true
4750

4851
# Configures the number of seconds to wait for build Bicep files.
4952
AZURE_BICEP_FILE_EXPANSION_TIMEOUT: 10
@@ -52,7 +55,7 @@ configuration:
5255
AZURE_BICEP_CHECK_TOOL: true
5356

5457
# Configure the minimum version of the Bicep CLI.
55-
AZURE_BICEP_MINIMUM_VERSION: '0.13.0'
58+
AZURE_BICEP_MINIMUM_VERSION: '0.19.5'
5659

5760
# Suppression ignores rules for a specific Azure resource by name.
5861
suppression:

0 commit comments

Comments
 (0)