Remediation

Manages an Azure Policy Remediation at the specified Scope.

Example Usage

using Pulumi;
using Azure = Pulumi.Azure;

class MyStack : Stack
{
    public MyStack()
    {
        var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
        {
            Location = "West Europe",
        });
        var exampleDefinition = new Azure.Policy.Definition("exampleDefinition", new Azure.Policy.DefinitionArgs
        {
            PolicyType = "Custom",
            Mode = "All",
            DisplayName = "my-policy-definition",
            PolicyRule = @"    {
    ""if"": {
      ""not"": {
        ""field"": ""location"",
        ""in"": ""[parameters('allowedLocations')]""
      }
    },
    ""then"": {
      ""effect"": ""audit""
    }
  }
",
            Parameters = @"    {
    ""allowedLocations"": {
      ""type"": ""Array"",
      ""metadata"": {
        ""description"": ""The list of allowed locations for resources."",
        ""displayName"": ""Allowed locations"",
        ""strongType"": ""location""
      }
    }
  }
",
        });
        var exampleAssignment = new Azure.Policy.Assignment("exampleAssignment", new Azure.Policy.AssignmentArgs
        {
            Scope = exampleResourceGroup.Id,
            PolicyDefinitionId = exampleDefinition.Id,
            Description = "Policy Assignment created via an Acceptance Test",
            DisplayName = "My Example Policy Assignment",
            Parameters = @"{
  ""allowedLocations"": {
    ""value"": [ ""West Europe"" ]
  }
}
",
        });
        var exampleRemediation = new Azure.Policy.Remediation("exampleRemediation", new Azure.Policy.RemediationArgs
        {
            Scope = exampleAssignment.Scope,
            PolicyAssignmentId = exampleAssignment.Id,
            LocationFilters = 
            {
                "West Europe",
            },
        });
    }

}
package main

import (
    "fmt"

    "github.com/pulumi/pulumi-azure/sdk/v3/go/azure/core"
    "github.com/pulumi/pulumi-azure/sdk/v3/go/azure/policy"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
            Location: pulumi.String("West Europe"),
        })
        if err != nil {
            return err
        }
        exampleDefinition, err := policy.NewDefinition(ctx, "exampleDefinition", &policy.DefinitionArgs{
            PolicyType:  pulumi.String("Custom"),
            Mode:        pulumi.String("All"),
            DisplayName: pulumi.String("my-policy-definition"),
            PolicyRule:  pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v%v", "    {\n", "    \"if\": {\n", "      \"not\": {\n", "        \"field\": \"location\",\n", "        \"in\": \"[parameters('allowedLocations')]\"\n", "      }\n", "    },\n", "    \"then\": {\n", "      \"effect\": \"audit\"\n", "    }\n", "  }\n")),
            Parameters:  pulumi.String(fmt.Sprintf("%v%v%v%v%v%v%v%v%v%v", "    {\n", "    \"allowedLocations\": {\n", "      \"type\": \"Array\",\n", "      \"metadata\": {\n", "        \"description\": \"The list of allowed locations for resources.\",\n", "        \"displayName\": \"Allowed locations\",\n", "        \"strongType\": \"location\"\n", "      }\n", "    }\n", "  }\n")),
        })
        if err != nil {
            return err
        }
        exampleAssignment, err := policy.NewAssignment(ctx, "exampleAssignment", &policy.AssignmentArgs{
            Scope:              exampleResourceGroup.ID(),
            PolicyDefinitionId: exampleDefinition.ID(),
            Description:        pulumi.String("Policy Assignment created via an Acceptance Test"),
            DisplayName:        pulumi.String("My Example Policy Assignment"),
            Parameters:         pulumi.String(fmt.Sprintf("%v%v%v%v%v", "{\n", "  \"allowedLocations\": {\n", "    \"value\": [ \"West Europe\" ]\n", "  }\n", "}\n")),
        })
        if err != nil {
            return err
        }
        _, err = policy.NewRemediation(ctx, "exampleRemediation", &policy.RemediationArgs{
            Scope:              exampleAssignment.Scope,
            PolicyAssignmentId: exampleAssignment.ID(),
            LocationFilters: pulumi.StringArray{
                pulumi.String("West Europe"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_definition = azure.policy.Definition("exampleDefinition",
    policy_type="Custom",
    mode="All",
    display_name="my-policy-definition",
    policy_rule="""    {
    "if": {
      "not": {
        "field": "location",
        "in": "[parameters('allowedLocations')]"
      }
    },
    "then": {
      "effect": "audit"
    }
  }
""",
    parameters="""    {
    "allowedLocations": {
      "type": "Array",
      "metadata": {
        "description": "The list of allowed locations for resources.",
        "displayName": "Allowed locations",
        "strongType": "location"
      }
    }
  }
""")
example_assignment = azure.policy.Assignment("exampleAssignment",
    scope=example_resource_group.id,
    policy_definition_id=example_definition.id,
    description="Policy Assignment created via an Acceptance Test",
    display_name="My Example Policy Assignment",
    parameters="""{
  "allowedLocations": {
    "value": [ "West Europe" ]
  }
}
""")
example_remediation = azure.policy.Remediation("exampleRemediation",
    scope=example_assignment.scope,
    policy_assignment_id=example_assignment.id,
    location_filters=["West Europe"])
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleDefinition = new azure.policy.Definition("exampleDefinition", {
    policyType: "Custom",
    mode: "All",
    displayName: "my-policy-definition",
    policyRule: `    {
    "if": {
      "not": {
        "field": "location",
        "in": "[parameters('allowedLocations')]"
      }
    },
    "then": {
      "effect": "audit"
    }
  }
`,
    parameters: `    {
    "allowedLocations": {
      "type": "Array",
      "metadata": {
        "description": "The list of allowed locations for resources.",
        "displayName": "Allowed locations",
        "strongType": "location"
      }
    }
  }
`,
});
const exampleAssignment = new azure.policy.Assignment("exampleAssignment", {
    scope: exampleResourceGroup.id,
    policyDefinitionId: exampleDefinition.id,
    description: "Policy Assignment created via an Acceptance Test",
    displayName: "My Example Policy Assignment",
    parameters: `{
  "allowedLocations": {
    "value": [ "West Europe" ]
  }
}
`,
});
const exampleRemediation = new azure.policy.Remediation("exampleRemediation", {
    scope: exampleAssignment.scope,
    policyAssignmentId: exampleAssignment.id,
    locationFilters: ["West Europe"],
});

Create a Remediation Resource

def Remediation(resource_name, opts=None, location_filters=None, name=None, policy_assignment_id=None, policy_definition_reference_id=None, scope=None, __props__=None);
func NewRemediation(ctx *Context, name string, args RemediationArgs, opts ...ResourceOption) (*Remediation, error)
public Remediation(string name, RemediationArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args RemediationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args RemediationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RemediationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Remediation Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The Remediation resource accepts the following input properties:

PolicyAssignmentId string

The resource ID of the policy assignment that should be remediated.

Scope string

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

LocationFilters List<string>

A list of the resource locations that will be remediated.

Name string

The name of the Policy Remediation. Changing this forces a new resource to be created.

PolicyDefinitionReferenceId string

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

PolicyAssignmentId string

The resource ID of the policy assignment that should be remediated.

Scope string

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

LocationFilters []string

A list of the resource locations that will be remediated.

Name string

The name of the Policy Remediation. Changing this forces a new resource to be created.

PolicyDefinitionReferenceId string

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

policyAssignmentId string

The resource ID of the policy assignment that should be remediated.

scope string

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

locationFilters string[]

A list of the resource locations that will be remediated.

name string

The name of the Policy Remediation. Changing this forces a new resource to be created.

policyDefinitionReferenceId string

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

policy_assignment_id str

The resource ID of the policy assignment that should be remediated.

scope str

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

location_filters List[str]

A list of the resource locations that will be remediated.

name str

The name of the Policy Remediation. Changing this forces a new resource to be created.

policy_definition_reference_id str

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

Outputs

All input properties are implicitly available as output properties. Additionally, the Remediation resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Remediation Resource

Get an existing Remediation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: RemediationState, opts?: CustomResourceOptions): Remediation
static get(resource_name, id, opts=None, location_filters=None, name=None, policy_assignment_id=None, policy_definition_reference_id=None, scope=None, __props__=None);
func GetRemediation(ctx *Context, name string, id IDInput, state *RemediationState, opts ...ResourceOption) (*Remediation, error)
public static Remediation Get(string name, Input<string> id, RemediationState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

LocationFilters List<string>

A list of the resource locations that will be remediated.

Name string

The name of the Policy Remediation. Changing this forces a new resource to be created.

PolicyAssignmentId string

The resource ID of the policy assignment that should be remediated.

PolicyDefinitionReferenceId string

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

Scope string

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

LocationFilters []string

A list of the resource locations that will be remediated.

Name string

The name of the Policy Remediation. Changing this forces a new resource to be created.

PolicyAssignmentId string

The resource ID of the policy assignment that should be remediated.

PolicyDefinitionReferenceId string

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

Scope string

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

locationFilters string[]

A list of the resource locations that will be remediated.

name string

The name of the Policy Remediation. Changing this forces a new resource to be created.

policyAssignmentId string

The resource ID of the policy assignment that should be remediated.

policyDefinitionReferenceId string

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

scope string

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

location_filters List[str]

A list of the resource locations that will be remediated.

name str

The name of the Policy Remediation. Changing this forces a new resource to be created.

policy_assignment_id str

The resource ID of the policy assignment that should be remediated.

policy_definition_reference_id str

The policy definition reference ID of the individual definition that should be remediated. Required when the policy assignment being remediated assigns a policy set definition.

scope str

The Scope at which the Policy Remediation should be applied. Changing this forces a new resource to be created. A scope must be a Resource ID out of one of the following list:

Package Details

Repository
https://github.com/pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.