How to dynamically exclude PSRule rules based on environment (DEV, QA, PROD)? #2953
Unanswered
mikkelh-SDU
asked this question in
Q&A
Replies: 1 comment 3 replies
|
Hi mikkelh-SDU, yes there is a few options you could use. Based on your provided sample code, these would probably be the most applicable:
For suppression groups, they work well when resources already use a naming or tagging convention, for example:
For separate option files, it's as easy as creating two option files and setting the
When you run PSRule you can specify the option file by Alternatively, you could also do the following, but it might add some additional complexity when authoring locally or running pipelines:
|
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi all, this might be a silly question
We have a use case where we want to apply different PSRule exclusions depending on the environment (e.g., DEV, QA, PROD). For example, in our DEV environment, we want to exclude rules like 'Azure.AppService.MinPlan', which we do want enforced in PROD.
Currently, I extract the environment name from the .bicepparam file like this:
Then I dynamically build the list of rules to exclude based on the environment:
This works, but it feels a bit clunky. Is there a more elegant or built-in way in PSRule to handle environment-specific rule exclusions—perhaps by referencing parameters from the Bicep or .bicepparam files directly, or by using profiles or conditions?
Any best practices or suggestions would be appreciated!
All reactions