Skip to content

Require

SYNOPSIS

A named compliance requirement. Describes the compliant state; the compiler inverts it.

SYNTAX

Require [-Description] <String> [-Body] <ScriptBlock> [<CommonParameters>]

DESCRIPTION

The statements in a Require all have to hold for a resource to be compliant. Bylaw inverts them into the policy's if condition, which finds the resources that break any of them, and adds the missing-field checks Azure needs (ADR-0004). A resource breaks the policy when it breaks any Require. In AuditIfNotExists and DeployIfNotExists, Require describes the related resource instead, and is emitted as the existence condition.

USED IN

Resource, AuditIfNotExists, DeployIfNotExists

EXAMPLES

Example 1

Require 'Public network access is disabled' {
    Field publicNetworkAccess | Must -Be 'Disabled'
}

Example 2

Require 'Secure transfer and TLS 1.2' {
    Field supportsHttpsTrafficOnly | Must -Be $true
    Field minimumTlsVersion | Must -Be 'TLS1_2'
}

PARAMETERS

-Description

What the requirement is, in words. It is kept in the source for readers and in error messages, and isn't emitted.

Type: String
Required: true
Position: 1
Accept pipeline input: false

-Body

The statements that describe a compliant resource: Must, Each, Count, AnyOf and AllOf.

Type: ScriptBlock
Required: true
Position: 2
Accept pipeline input: false