azure-vm-attach-user-mi

derived azure emits CanAttachIdentity

match

A conjunctive graph pattern. Variables (?x) bind node ids; every clause must hold.

{'principal': None} CanPassIdentity {'userMI': None}

where

?principal has EFFECTIVE Microsoft.ManagedIdentity/userAssignedIdentities/assign/action on ?userMI ?principal has EFFECTIVE Microsoft.Compute/virtualMachines/write on the target VM (existing or new)

emit

source typeIdentity
target typeCompute
source<principal>
target<virtualMachine (existing or new)>
permissionsMicrosoft.ManagedIdentity/userAssignedIdentities/assign/action Microsoft.Compute/virtualMachines/write
conditionsrole_compatibility

Narrative

{principal.name} can attach user-assigned MI {userMI.name} to VM {target.name} (assign/action + virtualMachines/write).

Raw rule rules/derived/azure/vm.yaml

id: azure-vm-attach-user-mi
emits: CanAttachIdentity
match:
- - principal: null
  - CanPassIdentity
  - userMI: null
where:
- ?principal has EFFECTIVE Microsoft.ManagedIdentity/userAssignedIdentities/assign/action on ?userMI
- ?principal has EFFECTIVE Microsoft.Compute/virtualMachines/write on the target VM (existing or new)
emit:
  source_type: Identity
  target_type: Compute
  source: <principal>
  target: <virtualMachine (existing or new)>
  permissions:
  - Microsoft.ManagedIdentity/userAssignedIdentities/assign/action
  - Microsoft.Compute/virtualMachines/write
  conditions:
  - role_compatibility
  false_positive_note: 'BOTH permissions are required: assign/action on the MI AND virtualMachines/write
    on the VM. Neither alone attaches the MI. Honor the assign/action resource scope.'
  narrative: '{principal.name} can attach user-assigned MI {userMI.name} to VM {target.name} (assign/action
    + virtualMachines/write).'
move · open · esc close