Skip to content

Add Azure ResourceGroup enrichment to CloudMetadata#697

Merged
slashben merged 2 commits intomainfrom
add-azure-resourcegroup
Jan 27, 2026
Merged

Add Azure ResourceGroup enrichment to CloudMetadata#697
slashben merged 2 commits intomainfrom
add-azure-resourcegroup

Conversation

@slashben
Copy link
Contributor

@slashben slashben commented Jan 27, 2026

Summary

  • Add enrichment of Azure ResourceGroup to CloudMetadata from Kubernetes node spec and IMDS
  • Supports both Kubernetes deployments (via node providerID) and host deployments (via IMDS)
  • Updated armoapi-go dependency to v0.0.670
  • Added comprehensive unit tests

Changes

  • Add enrichCloudMetadataForAzure function to parse ResourceGroup from node spec.providerID
  • Add parseAzureResourceGroup helper to extract ResourceGroup from Azure providerID format: azure:///subscriptions/{sub}/resourceGroups/{rg}/providers/...
  • Update fetchAzureMetadata to include ResourceGroup from Azure IMDS resourceGroupName endpoint
  • Call enrichment function in GetCloudMetadata for Kubernetes nodes
  • Import corev1 for proper node type handling
  • Update armoapi-go to v0.0.670
  • Add unit tests for parseAzureResourceGroup and enrichCloudMetadataForAzure with 14 test cases

Test Coverage

  • ✅ Tests for various providerID formats (valid, malformed, edge cases)
  • ✅ Tests for case-insensitive matching
  • ✅ Tests for guard conditions (nil checks, provider checks, already-set ResourceGroup)
  • ✅ All tests passing

Dependencies

  • Depends on armoapi-go v0.0.670 (already released with ResourceGroup field)

Test plan

  • Unit tests added and passing (14 test cases)
  • Verify ResourceGroup is populated for Azure Kubernetes nodes
  • Verify ResourceGroup is populated from IMDS for host deployments
  • Verify RuntimeAlerts include resource_group in cloudMetadata

Add enrichment of Azure ResourceGroup to CloudMetadata from two sources:
1. Kubernetes node spec providerID for K8s deployments
2. Azure IMDS resourceGroupName endpoint for host deployments

Changes:
- Add enrichCloudMetadataForAzure function to parse ResourceGroup from node providerID
- Add parseAzureResourceGroup helper to extract ResourceGroup from Azure providerID format
- Update fetchAzureMetadata to include ResourceGroup from IMDS
- Call enrichCloudMetadataForAzure in GetCloudMetadata

Depends on armoapi-go ResourceGroup field addition.
Signed-off-by: Ben <ben@armosec.io>
Signed-off-by: Ben <ben@armosec.io>
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

This PR bumps the armosec/armoapi-go dependency and adds Azure-specific metadata enrichment to the cloud metadata module. It introduces functions to extract ResourceGroup from Azure provider IDs and enriches CloudMetadata accordingly during node processing.

Changes

Cohort / File(s) Summary
Dependency Update
go.mod
Bumps armosec/armoapi-go from v0.0.667 to v0.0.670
Azure Metadata Enrichment
pkg/cloudmetadata/metadata.go
Adds enrichCloudMetadataForAzure() to extract and populate ResourceGroup from Azure node provider IDs; adds parseAzureResourceGroup() helper for parsing; integrates enrichment into GetCloudMetadata() flow; updates fetchAzureMetadata() to include ResourceGroup field; adds corev1 import

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

release

Suggested reviewers

  • amirmalka

Poem

🐰 A rabbit hops through Azure clouds so bright,
ResourceGroups now parsed with parsing might,
From providerID strings, we extract with care,
Metadata enriched, cloud details laid bare! ☁️✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly summarizes the main change: adding Azure ResourceGroup enrichment to CloudMetadata, which is the primary objective of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@slashben slashben merged commit a13900b into main Jan 27, 2026
27 checks passed
@slashben slashben deleted the add-azure-resourcegroup branch January 27, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants