We recommend using Azure Native.
azure.policy.getPolicyDefintion
Explore with Pulumi AI
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)
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
})
}
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 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}
Using getPolicyDefintion
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getPolicyDefintion(args: GetPolicyDefintionArgs, opts?: InvokeOptions): Promise<GetPolicyDefintionResult>
function getPolicyDefintionOutput(args: GetPolicyDefintionOutputArgs, opts?: InvokeOptions): Output<GetPolicyDefintionResult>
def get_policy_defintion(display_name: Optional[str] = None,
management_group_name: Optional[str] = None,
name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetPolicyDefintionResult
def get_policy_defintion_output(display_name: Optional[pulumi.Input[str]] = None,
management_group_name: Optional[pulumi.Input[str]] = None,
name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetPolicyDefintionResult]
func GetPolicyDefintion(ctx *Context, args *GetPolicyDefintionArgs, opts ...InvokeOption) (*GetPolicyDefintionResult, error)
func GetPolicyDefintionOutput(ctx *Context, args *GetPolicyDefintionOutputArgs, opts ...InvokeOption) GetPolicyDefintionResultOutput
> Note: This function is named GetPolicyDefintion
in the Go SDK.
public static class GetPolicyDefintion
{
public static Task<GetPolicyDefintionResult> InvokeAsync(GetPolicyDefintionArgs args, InvokeOptions? opts = null)
public static Output<GetPolicyDefintionResult> Invoke(GetPolicyDefintionInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetPolicyDefintionResult> getPolicyDefintion(GetPolicyDefintionArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: azure:policy/getPolicyDefintion:getPolicyDefintion
arguments:
# arguments dictionary
The following arguments are supported:
- Display
Name string 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 thename
property instead.- Management
Group stringName - Only retrieve Policy Definitions from this Management Group.
- Name string
- Specifies the name of the Policy Definition. Conflicts with
display_name
.
- Display
Name string 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 thename
property instead.- Management
Group stringName - Only retrieve Policy Definitions from this Management Group.
- Name string
- Specifies the name of the Policy Definition. Conflicts with
display_name
.
- display
Name String 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 thename
property instead.- management
Group StringName - Only retrieve Policy Definitions from this Management Group.
- name String
- Specifies the name of the Policy Definition. Conflicts with
display_name
.
- display
Name string 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 thename
property instead.- management
Group stringName - Only retrieve Policy Definitions from this Management Group.
- name string
- Specifies the name of the Policy Definition. Conflicts with
display_name
.
- display_
name str 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 thename
property instead.- management_
group_ strname - Only retrieve Policy Definitions from this Management Group.
- name str
- Specifies the name of the Policy Definition. Conflicts with
display_name
.
- display
Name String 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 thename
property instead.- management
Group StringName - Only retrieve Policy Definitions from this Management Group.
- name String
- Specifies the name of the Policy Definition. Conflicts with
display_name
.
getPolicyDefintion Result
The following output properties are available:
- Description string
- The Description of the Policy.
- Display
Name string - Id string
- The provider-assigned unique ID for this managed resource.
- Metadata string
- Any Metadata defined in the Policy.
- Mode string
- The Mode of the Policy.
- Name string
- Parameters string
- Any Parameters defined in the Policy.
- Policy
Rule string - The Rule as defined (in JSON) in the Policy.
- Policy
Type string - The Type of the Policy. Possible values are
BuiltIn
,Custom
andNotSpecified
. - Role
Definition List<string>Ids - A list of role definition id extracted from
policy_rule
required for remediation. - Type string
- The Type of Policy.
- Management
Group stringName
- Description string
- The Description of the Policy.
- Display
Name string - Id string
- The provider-assigned unique ID for this managed resource.
- Metadata string
- Any Metadata defined in the Policy.
- Mode string
- The Mode of the Policy.
- Name string
- Parameters string
- Any Parameters defined in the Policy.
- Policy
Rule string - The Rule as defined (in JSON) in the Policy.
- Policy
Type string - The Type of the Policy. Possible values are
BuiltIn
,Custom
andNotSpecified
. - Role
Definition []stringIds - A list of role definition id extracted from
policy_rule
required for remediation. - Type string
- The Type of Policy.
- Management
Group stringName
- description String
- The Description of the Policy.
- display
Name String - id String
- The provider-assigned unique ID for this managed resource.
- metadata String
- Any Metadata defined in the Policy.
- mode String
- The Mode of the Policy.
- name String
- parameters String
- Any Parameters defined in the Policy.
- policy
Rule String - The Rule as defined (in JSON) in the Policy.
- policy
Type String - The Type of the Policy. Possible values are
BuiltIn
,Custom
andNotSpecified
. - role
Definition List<String>Ids - A list of role definition id extracted from
policy_rule
required for remediation. - type String
- The Type of Policy.
- management
Group StringName
- description string
- The Description of the Policy.
- display
Name string - id string
- The provider-assigned unique ID for this managed resource.
- metadata string
- Any Metadata defined in the Policy.
- mode string
- The Mode of the Policy.
- name string
- parameters string
- Any Parameters defined in the Policy.
- policy
Rule string - The Rule as defined (in JSON) in the Policy.
- policy
Type string - The Type of the Policy. Possible values are
BuiltIn
,Custom
andNotSpecified
. - role
Definition string[]Ids - A list of role definition id extracted from
policy_rule
required for remediation. - type string
- The Type of Policy.
- management
Group stringName
- description str
- The Description of the Policy.
- display_
name str - id str
- The provider-assigned unique ID for this managed resource.
- metadata str
- Any Metadata defined in the Policy.
- mode str
- The Mode of the Policy.
- name str
- parameters str
- Any Parameters defined in the Policy.
- policy_
rule str - The Rule as defined (in JSON) in the Policy.
- policy_
type str - The Type of the Policy. Possible values are
BuiltIn
,Custom
andNotSpecified
. - role_
definition_ Sequence[str]ids - A list of role definition id extracted from
policy_rule
required for remediation. - type str
- The Type of Policy.
- management_
group_ strname
- description String
- The Description of the Policy.
- display
Name String - id String
- The provider-assigned unique ID for this managed resource.
- metadata String
- Any Metadata defined in the Policy.
- mode String
- The Mode of the Policy.
- name String
- parameters String
- Any Parameters defined in the Policy.
- policy
Rule String - The Rule as defined (in JSON) in the Policy.
- policy
Type String - The Type of the Policy. Possible values are
BuiltIn
,Custom
andNotSpecified
. - role
Definition List<String>Ids - A list of role definition id extracted from
policy_rule
required for remediation. - type String
- The Type of Policy.
- management
Group StringName
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.