Azure / PSRule.Rules.Azure

Rules to validate Azure resources and infrastructure as code (IaC) using PSRule.
https://azure.github.io/PSRule.Rules.Azure/
MIT License
387 stars 84 forks source link

[RULE] Virtual Network Gateways should have customer controlled maintenance configurations enabled/configured #2910

Closed jtracey93 closed 3 months ago

jtracey93 commented 3 months ago

Existing rule

No response

Suggested rule

Virtual Network Gateways should have customer controlled maintenance configurations enabled/configured as per: https://azure.github.io/Azure-Proactive-Resiliency-Library-v2/azure-resources/Network/virtualNetworkGateways/#configure-customer-controlled-expressroute-gateway-maintenance

Pillar

Reliability

Additional context

No response

BenjaminEngeset commented 3 months ago

:shipit:

BenjaminEngeset commented 3 months ago

Hi @BernieWhite,

I wanted to discuss some technical details regarding the configuration and attachment, which involve two different extension resource types. Since extension resources cannot be declared within the parent resource, how does PSRule identify their relationship with the gateway resource type object?

I believe the PSRule engine performs a specific action because we have existing rules for this (which I created but can’t recall the internal logic now).

Does the PSRule engine essentially place the extension resources within the resources block of the parent resource, given that the extension resource has a scope property that maps to an object PSRule will analyze also? Or does it create a dummy parent object based on the scope property of the extension resource and then put extension resources that maps to the same parent dummy object under the resources block of the parent dummy object?

BernieWhite commented 3 months ago

@BenjaminEngeset Should be fine. They should appear as scoped resources which PSRule will handle and automatically nest under resources property like a normal child resource. We'd need to add support to handle export for in-flight cases though.

Here is an example: https://github.com/Azure/PSRule.Rules.Azure/blob/6ca47280887ea042b3400b3fd8ae8bb1d5a937a3/src/PSRule.Rules.Azure/rules/Azure.VM.Rule.ps1#L281-L285

BernieWhite commented 3 months ago

https://learn.microsoft.com/en-gb/azure/well-architected/reliability/metrics