Skip to content

Azure PsRule, check if resource exists, if so validate that there is another resource with it as parent #1969

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

You must be logged in to vote

@C0smin Deployments are streamed through the pipeline for both Bicep and ARM templates. So this is probably the answer, although if you have any bicep sample code that would help.

To write a rule to check a deployment use the Microsoft.Resources/deployments type. This will allow you to evaluate a deployment prior to it being expanded, which may not be ideal but it would have a similar result as $PSRule.GetContent($TargetObject)[0].

Some examples are here: https://github.com/Azure/PSRule.Rules.Azure/blob/main/src/PSRule.Rules.Azure/rules/Azure.Deployment.Rule.ps1


Alternatively you may be able to check for a sub-resource of the protected object. PSRule for Azure automatically nests sub-res…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@C0smin
Comment options

@BernieWhite
Comment options

@C0smin
Comment options

Answer selected by C0smin
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