Skip to content

Commit fa4f386

Browse files
committed
fix: incorrect warnings for policies
1 parent ba1885e commit fa4f386

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

src/azure-policyassignment/lib/policy-assignment.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,6 @@ export class PolicyAssignment extends AzapiResource {
350350

351351
this.props = props;
352352

353-
// Validate that location is provided when identity is specified
354-
if (props.identity && !this.location) {
355-
throw new Error(
356-
`Location is required for Policy Assignment "${props.name || id}" when identity is specified. ` +
357-
`The managed identity must be provisioned in a specific Azure region.`,
358-
);
359-
}
360-
361353
// Extract properties from the AZAPI resource outputs using Terraform interpolation
362354

363355
// Create Terraform outputs for easy access and referencing from other resources
@@ -445,8 +437,8 @@ export class PolicyAssignment extends AzapiResource {
445437
// Add identity if provided
446438
if (typedProps.identity) {
447439
body.identity = typedProps.identity;
448-
// Azure requires location when identity is specified for managed identity provisioning
449-
body.location = typedProps.location;
440+
// Note: location is NOT added to the body for policy assignments
441+
// It's handled by the AZAPI provider config for identity provisioning
450442
}
451443

452444
return body;

src/azure-policyassignment/test/policy-assignment.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ describe("PolicyAssignment - Unified Implementation", () => {
9191
metadata: {
9292
assignedBy: "admin@example.com",
9393
},
94-
location: "eastus",
9594
identity: {
9695
type: "SystemAssigned",
9796
},
@@ -341,7 +340,6 @@ describe("PolicyAssignment - Unified Implementation", () => {
341340
metadata: {
342341
assignedBy: "admin@example.com",
343342
},
344-
location: "eastus",
345343
identity: {
346344
type: "SystemAssigned",
347345
},
@@ -418,7 +416,6 @@ describe("PolicyAssignment - Unified Implementation", () => {
418416
policyDefinitionId:
419417
"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/policyDefinitions/test-policy",
420418
scope: "/subscriptions/00000000-0000-0000-0000-000000000000",
421-
location: "eastus",
422419
identity: {
423420
type: "SystemAssigned",
424421
},
@@ -434,7 +431,6 @@ describe("PolicyAssignment - Unified Implementation", () => {
434431
policyDefinitionId:
435432
"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/policyDefinitions/test-policy",
436433
scope: "/subscriptions/00000000-0000-0000-0000-000000000000",
437-
location: "eastus",
438434
identity: {
439435
type: "UserAssigned",
440436
userAssignedIdentities: {
@@ -455,7 +451,6 @@ describe("PolicyAssignment - Unified Implementation", () => {
455451
policyDefinitionId:
456452
"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/policyDefinitions/test-policy",
457453
scope: "/subscriptions/00000000-0000-0000-0000-000000000000",
458-
location: "eastus",
459454
identity: {
460455
type: "None",
461456
},

src/core-azure/lib/azapi/schema-mapper/schema-mapper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ export class SchemaMapper {
542542
"enableTransformation",
543543
"ignoreChanges",
544544
"resourceGroupId",
545+
"parentId", // AZAPI provider internal property for resource hierarchy
545546
"monitoring", // Framework-level monitoring configuration
546547
"virtualNetworkId", // Framework-level dependency tracking for child resources
547548
]);

0 commit comments

Comments
 (0)