getPolicyDefintion

Use this data source to access information about a Policy Definition, both custom and built in. Retrieves Policy Definitions from your current subscription by default.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.policy.getPolicyDefintion({
displayName: "Allowed resource types",
});
export const id = example.then(example => example.id);
import pulumi
import pulumi_azure as azure
example = azure.policy.get_policy_defintion(display_name="Allowed resource types")
pulumi.export("id", example.id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Policy.GetPolicyDefintion.Invoke(new()
{
DisplayName = "Allowed resource types",
});
return new Dictionary<string, object?>
{
["id"] = example.Apply(getPolicyDefintionResult => getPolicyDefintionResult.Id),
};
});
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/policy"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := policy.GetPolicyDefintion(ctx, &policy.GetPolicyDefintionArgs{
DisplayName: pulumi.StringRef("Allowed resource types"),
}, nil)
if err != nil {
return err
}
ctx.Export("id", example.Id)
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.policy.PolicyFunctions;
import com.pulumi.azure.policy.inputs.GetPolicyDefintionArgs;
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) {
final var example = PolicyFunctions.getPolicyDefintion(GetPolicyDefintionArgs.builder()
.displayName("Allowed resource types")
.build());
ctx.export("id", example.applyValue(getPolicyDefintionResult -> getPolicyDefintionResult.id()));
}
}
variables:
example:
fn::invoke:
function: azure:policy:getPolicyDefintion
arguments:
displayName: Allowed resource types
outputs:
id: ${example.id}

Return

A collection of values returned by getPolicyDefintion.

Parameters

argument

A collection of arguments for invoking getPolicyDefintion.


suspend fun getPolicyDefintion(displayName: String? = null, managementGroupName: String? = null, name: String? = null): GetPolicyDefintionResult

Return

A collection of values returned by getPolicyDefintion.

Parameters

displayName

Specifies the display name of the Policy Definition. Conflicts with name.

NOTE Looking up policies by display_name is not recommended by the Azure Policy team as the property is not unique nor immutable. As such errors may occur when there are multiple policy definitions with same display name or the display name is changed. To avoid these types of errors you may wish to use the name property instead.

managementGroupName

Only retrieve Policy Definitions from this Management Group.

name

Specifies the name of the Policy Definition. Conflicts with display_name.

See also


Return

A collection of values returned by getPolicyDefintion.

Parameters

argument

Builder for com.pulumi.azure.policy.kotlin.inputs.GetPolicyDefintionPlainArgs.

See also