turbot/steampipe-mod-azure-compliance

Control: Add system-assigned managed identity to enable Guest Configuration assignments on virtual machines with no identities

Description

This policy adds a system-assigned managed identity to virtual machines hosted in Azure that are supported by Guest Configuration but do not have any managed identities. A system-assigned managed identity is a prerequisite for all Guest Configuration assignments and must be added to machines before using any Guest Configuration policy definitions.

Usage

Run the control in your terminal:

powerpipe control run azure_compliance.control.compute_vm_guest_configuration_with_no_managed_identity

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run azure_compliance.control.compute_vm_guest_configuration_with_no_managed_identity --share

SQL

This control uses a named query:

with gc_installed_vm as (
select
distinct a.vm_id,
title
from
azure_compute_virtual_machine as a,
jsonb_array_elements(extensions) as b
where
b ->> 'Publisher' = 'Microsoft.GuestConfiguration'
)
select
a.vm_id as resource,
case
when b.vm_id is null then 'skip'
when b.vm_id is not null and identity ->> 'type' is not null then 'ok'
else 'alarm'
end as status,
case
when b.vm_id is null then a.title || ' guest configuration extension not installed.'
when b.vm_id is not null and identity ->> 'type' is not null then a.title || ' guest configuration extension installed with ' || (identity ->> 'type') || ' managed identity.'
else a.title || ' guest configuration extension not installed with managed identity.'
end as reason
, a.resource_group as resource_group
, sub.display_name as subscription
from
azure_compute_virtual_machine as a
left join gc_installed_vm as b on a.vm_id = b.vm_id,
azure_subscription as sub
where
sub.subscription_id = a.subscription_id;

Tags