Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSRule baseline and minium samples #236

Merged
merged 1 commit into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bicep-build-to-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:

# Add pipeline tests for Azure Well-Architected Framework
- name: Run PSRule analysis
uses: Microsoft/ps-rule@v2.0.0
uses: Microsoft/ps-rule@v2.1.0
with:
modules: PSRule.Rules.Azure
baseline: Azure.GA_2022_03
Expand Down
23 changes: 23 additions & 0 deletions .ps-rule/Minimum.Rule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

---
# Synopsis: Ignore the minimum sample configuration.
apiVersion: github.com/microsoft/PSRule/v1
kind: SuppressionGroup
metadata:
name: ALZ.MinimumSample
spec:
rule:
- Azure.Firewall.Mode
- Azure.VNG.VPNAvailabilityZoneSKU
- Azure.PublicIP.AvailabilityZone
- Azure.VNG.VPNActiveActive
- Azure.PublicIP.StandardSKU
if:
allOf:
- type: '.'
in:
- Microsoft.Network/azureFirewalls
- Microsoft.Network/publicIPAddresses
- source: 'Template'
endsWith:
- 'minimum.sample.bicep'
15 changes: 15 additions & 0 deletions .ps-rule/en/ALZ.MinimumSample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ignore minimum sample

## SYNOPSIS

Ignore the minimum sample configuration that may not be WAF compliant.
See https://github.com/Azuure/ALZ-Bicep/blob/main/.ps-rule/en/ALZ.MinimumSample.md.

## DESCRIPTION

The _minimum_ sample provides a basic configuration.
It is typically less complex, and has requires fewer requirements.
This make is most suitable for early development and testing.

The basic configuration may not have all the features required for alignment to the Well-Architected Framework.
Consider using the _baseline_ sample for enterprise environments.
54 changes: 54 additions & 0 deletions .vscode/bicep.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"Bicep minimum sample": {
"scope": "bicep",
"prefix": "bicep-minimum-sample",
"description": "A minmum sample for testing and examples.",
"body": [
"//",
"// Minimum deployment sample",
"//",
"",
"// Use this sample to deploy the minimum resource configuration.",
"",
"targetScope = 'resourceGroup'",
"",
"@description('The Azure location to deploy to.')",
"param location string = resourceGroup().location",
"",
"@description('Minimum resource configuration')",
"module ${1} '../${2}}.bicep' = {",
" name: '${1}'",
" params: {",
" parLocation: location",
" parTags: {}",
" }",
"}"
]
},
"Bicep baseline sample": {
"scope": "bicep",
"prefix": "bicep-baseline-sample",
"description": "A sample that aligned to WAF recommendations.",
"body": [
"//",
"// Baseline deployment sample",
"//",
"",
"// Use this sample to deploy a Well-Architected aligned resource configuration.",
"",
"targetScope = 'resourceGroup'",
"",
"@description('The Azure location to deploy to.')",
"param location string = resourceGroup().location",
"",
"@description('Baseline resource configuration')",
"module ${1} '../${2}}.bicep' = {",
" name: '${1}'",
" params: {",
" parLocation: location",
" parTags: {}",
" }",
"}"
]
}
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"recommendations": [
"ms-azuretools.vscode-bicep",
"vsls-contrib.codetour",
"msazurermtools.azurerm-vscode-tools",
"bencoleman.armview",
"bewhite.psrule-vscode"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Baseline deployment sample
//

// Use this sample to deploy a Well-Architected aligned resource configuration.

targetScope = 'resourceGroup'

@description('The Azure location to deploy to.')
param location string = resourceGroup().location

@description('Baseline resource configuration')
module baseline_hub_network '../hubNetworking.bicep' = {
name: 'baseline_hub_network'
params: {
parLocation: location
parPublicIPSku: 'Standard'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Minimum deployment sample
//

// Use this sample to deploy the minimum resource configuration.

targetScope = 'resourceGroup'

@description('The Azure location to deploy to.')
param location string = resourceGroup().location

@description('Minimum resource configuration')
module minimum_hub_network '../hubNetworking.bicep' = {
name: 'minimum_hub_network'
params: {
parLocation: location
}
}
25 changes: 25 additions & 0 deletions infra-as-code/bicep/modules/publicIp/samples/baseline.sample.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Baseline deployment sample
//

// Use this sample to deploy a Well-Architected aligned resource configuration.

targetScope = 'resourceGroup'

@description('The Azure location to deploy to.')
param location string = resourceGroup().location

@description('Baseline resource configuration')
module baseline_public_ip '../publicIp.bicep' = {
name: 'baseline_public_ip'
params: {
parPublicIPName: 'pip-baseline-ip'
parLocation: location
parPublicIPProperties: { }
parPublicIPSku: {
name: 'Standard'
tier: 'Regional'
}
parTags: {}
}
}
25 changes: 25 additions & 0 deletions infra-as-code/bicep/modules/publicIp/samples/minimum.sample.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Minimum deployment sample
//

// Use this sample to deploy the minimum resource configuration.

targetScope = 'resourceGroup'

@description('The Azure location to deploy to.')
param location string = resourceGroup().location

@description('Minimum resource configuration')
module minimum_public_ip '../publicIp.bicep' = {
name: 'minimum_public_ip'
params: {
parPublicIPName: 'pip-minimum-ip'
parLocation: location
parPublicIPProperties: { }
parPublicIPSku: {
name: 'Basic'
tier: 'Regional'
}
parTags: {}
}
}
12 changes: 11 additions & 1 deletion ps-rule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ include:

# Require a minimum version of modules that include referenced baseline.
requires:
PSRule.Rules.Azure: '@pre >=1.14.2'
PSRule: '@pre >=2.1.0'
PSRule.Rules.Azure: '@pre >=1.15.2'

# Reference the repository in output.
repository:
Expand Down Expand Up @@ -50,10 +51,19 @@ input:
# Include samples/ test files from modules
- '!infra-as-code/bicep/modules/**/samples/*.bicep'

binding:
preferTargetInfo: true
targetType:
- resourceType
- type

rule:
exclude:
# Ignore these recommendations for this repo.
- Azure.Resource.UseTags
- Azure.ACR.MinSku
- Azure.ACR.ContentTrust
- Azure.Policy.AssignmentAssignedBy

# Currently a bug as of v1.15.2. Review in the next release.
- Azure.PublicIP.Name