Skip to content

Custom rule always fails #1332

Answered by BernieWhite
majorku5anagi asked this question in Q&A
Discussion options

You must be logged in to vote

@majorku5anagi Thanks for asking the question.

In short, when PSRule processes Azure resources there is additional objects that may not be obvious. There is three entries for countryTag.Rule. It is the additional objects that are failing, and the storage account is passing.

To solve your problem you could set a pre-condition. The docs provides this example -Type 'Microsoft.Resources/resourceGroups' in this section:

# Synopsis: Resource Groups must have all mandatory tags defined.
Rule 'Org.Azure.RG.Tags' -Type 'Microsoft.Resources/resourceGroups' {
    $hasTags = $Assert.HasField($TargetObject, 'Tags')
    if (!$hasTags.Result) {
        return $hasTags
    }

    # <Code for custom tags …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@majorku5anagi
Comment options

@BernieWhite
Comment options

Answer selected by majorku5anagi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1331 on March 26, 2022 06:07.