Resource¶
SYNOPSIS¶
Scopes the policy to a resource type and sets the alias resolution context. Resource * means no type condition. Every policy has one; the { } block after it is optional.
SYNTAX¶
Resource [-Type] <String> [[-Body] <ScriptBlock>] [<CommonParameters>]
DESCRIPTION¶
Resource emits a type condition, and short field names inside it are resolved against that type's aliases. With Resource *, the policy applies to every resource type, and fields are reserved fields such as location or tags, or full aliases. Without a block, every resource of the type is selected, as with AuditIfNotExists and DeployIfNotExists, whose conditions are in their own block.
USED IN¶
Policy
EXAMPLES¶
Example 1¶
Resource 'Microsoft.Storage/storageAccounts' {
Require 'TLS 1.2 or later' {
Field minimumTlsVersion | Must -Be 'TLS1_2'
}
}
Example 2¶
Resource * {
Require 'An allowed location' {
Field location | Must -BeIn (Param AllowedLocations)
}
}
Example 3¶
Resource 'Microsoft.KeyVault/vaults'
Every key vault, with no { } block and so no requirements: for an AuditIfNotExists or DeployIfNotExists policy, whose conditions are in its own block.
PARAMETERS¶
-Type¶
The resource type, e.g. Microsoft.Storage/storageAccounts, or * for every type.
Type: String
Required: true
Position: 1
Accept pipeline input: false
-Body¶
Optional: without it, every resource of the type is selected (ADR-0002).
Type: ScriptBlock
Required: false
Position: 2
Accept pipeline input: false