Definition
Manages a policy rule definition on a management group or your provider subscription. Policy definitions do not take effect until they are assigned to a scope using a Policy Assignment.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.policy.Definition;
import com.pulumi.azure.policy.DefinitionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var policy = new Definition("policy", DefinitionArgs.builder()
.displayName("acceptance test policy definition")
.metadata("""
{
"category": "General"
}
""")
.mode("Indexed")
.parameters("""
{
"allowedLocations": {
"type": "Array",
"metadata": {
"description": "The list of allowed locations for resources.",
"displayName": "Allowed locations",
"strongType": "location"
}
}
}
""")
.policyRule("""
{
"if": {
"not": {
"field": "location",
"in": "[parameters('allowedLocations')]"
}
},
"then": {
"effect": "audit"
}
}
""")
.policyType("Custom")
.build());
}
}
Content copied to clipboard
Import
Policy Definitions can be imported using the policy name
, e.g.
$ pulumi import azure:policy/definition:Definition examplePolicy /subscriptions/<SUBSCRIPTION_ID>/providers/Microsoft.Authorization/policyDefinitions/<POLICY_NAME>
Content copied to clipboard
or
$ pulumi import azure:policy/definition:Definition examplePolicy /providers/Microsoft.Management/managementgroups/<MANGAGEMENT_GROUP_ID>/providers/Microsoft.Authorization/policyDefinitions/<POLICY_NAME>
Content copied to clipboard
Properties
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
The policy resource manager mode that allows you to specify which resource types will be evaluated. Possible values are All
, Indexed
, Microsoft.ContainerService.Data
, Microsoft.CustomerLockbox.Data
, Microsoft.DataCatalog.Data
, Microsoft.KeyVault.Data
, Microsoft.Kubernetes.Data
, Microsoft.MachineLearningServices.Data
, Microsoft.Network.Data
and Microsoft.Synapse.Data
.