1. Packages
  2. Impart Security
  3. API Docs
  4. Rule
Impart Security v0.10.0 published on Tuesday, May 20, 2025 by Impart Security

impart.Rule

Explore with Pulumi AI

impart logo
Impart Security v0.10.0 published on Tuesday, May 20, 2025 by Impart Security

    Manage a rule.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as fs from "fs";
    import * as impart from "@impart-security/pulumi-impart";
    
    // Create a new rule script
    const example = new impart.Rule("example", {
        name: "example",
        disabled: false,
        description: "Rule description",
        sourceFile: `${path.module}/rule.js`,
        sourceHash: "<sha256 hash for the source_file content>",
        blockingEffect: "block",
        type: "script",
    });
    // Create a new rule recipe with content
    const exampleRuleRecipe = new impart.Rule("exampleRuleRecipe", {
        name: "example",
        disabled: false,
        description: "Rule description",
        content: fs.readFileSync(`${path.module}/rule.json`, "utf8"),
        blockingEffect: "block",
        type: "recipe",
    });
    
    import pulumi
    import pulumi_impart as impart
    
    # Create a new rule script
    example = impart.Rule("example",
        name="example",
        disabled=False,
        description="Rule description",
        source_file=f"{path['module']}/rule.js",
        source_hash="<sha256 hash for the source_file content>",
        blocking_effect="block",
        type="script")
    # Create a new rule recipe with content
    example_rule_recipe = impart.Rule("exampleRuleRecipe",
        name="example",
        disabled=False,
        description="Rule description",
        content=(lambda path: open(path).read())(f"{path['module']}/rule.json"),
        blocking_effect="block",
        type="recipe")
    
    package main
    
    import (
    	"fmt"
    	"os"
    
    	"github.com/impart-security/pulumi-impart/sdk/go/impart"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func readFileOrPanic(path string) pulumi.StringPtrInput {
    	data, err := os.ReadFile(path)
    	if err != nil {
    		panic(err.Error())
    	}
    	return pulumi.String(string(data))
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Create a new rule script
    		_, err := impart.NewRule(ctx, "example", &impart.RuleArgs{
    			Name:           pulumi.String("example"),
    			Disabled:       pulumi.Bool(false),
    			Description:    pulumi.String("Rule description"),
    			SourceFile:     pulumi.Sprintf("%v/rule.js", path.Module),
    			SourceHash:     pulumi.String("<sha256 hash for the source_file content>"),
    			BlockingEffect: pulumi.String("block"),
    			Type:           pulumi.String("script"),
    		})
    		if err != nil {
    			return err
    		}
    		// Create a new rule recipe with content
    		_, err = impart.NewRule(ctx, "exampleRuleRecipe", &impart.RuleArgs{
    			Name:           pulumi.String("example"),
    			Disabled:       pulumi.Bool(false),
    			Description:    pulumi.String("Rule description"),
    			Content:        pulumi.String(readFileOrPanic(fmt.Sprintf("%v/rule.json", path.Module))),
    			BlockingEffect: pulumi.String("block"),
    			Type:           pulumi.String("recipe"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using Pulumi;
    using Impart = Pulumi.Impart;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a new rule script
        var example = new Impart.Rule("example", new()
        {
            Name = "example",
            Disabled = false,
            Description = "Rule description",
            SourceFile = $"{path.Module}/rule.js",
            SourceHash = "<sha256 hash for the source_file content>",
            BlockingEffect = "block",
            Type = "script",
        });
    
        // Create a new rule recipe with content
        var exampleRuleRecipe = new Impart.Rule("exampleRuleRecipe", new()
        {
            Name = "example",
            Disabled = false,
            Description = "Rule description",
            Content = File.ReadAllText($"{path.Module}/rule.json"),
            BlockingEffect = "block",
            Type = "recipe",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.impart.Rule;
    import com.pulumi.impart.RuleArgs;
    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) {
            // Create a new rule script
            var example = new Rule("example", RuleArgs.builder()
                .name("example")
                .disabled(false)
                .description("Rule description")
                .sourceFile(String.format("%s/rule.js", path.module()))
                .sourceHash("<sha256 hash for the source_file content>")
                .blockingEffect("block")
                .type("script")
                .build());
    
            // Create a new rule recipe with content
            var exampleRuleRecipe = new Rule("exampleRuleRecipe", RuleArgs.builder()
                .name("example")
                .disabled(false)
                .description("Rule description")
                .content(Files.readString(Paths.get(String.format("%s/rule.json", path.module()))))
                .blockingEffect("block")
                .type("recipe")
                .build());
    
        }
    }
    
    resources:
      # Create a new rule script
      example:
        type: impart:Rule
        properties:
          name: example
          disabled: false
          description: Rule description
          sourceFile: ${path.module}/rule.js
          sourceHash: <sha256 hash for the source_file content>
          blockingEffect: block
          type: script
      # Create a new rule recipe with content
      exampleRuleRecipe:
        type: impart:Rule
        properties:
          name: example
          disabled: false
          description: Rule description
          content:
            fn::readFile: ${path.module}/rule.json
          blockingEffect: block
          type: recipe
    

    Create Rule Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Rule(name: string, args: RuleArgs, opts?: CustomResourceOptions);
    @overload
    def Rule(resource_name: str,
             args: RuleArgs,
             opts: Optional[ResourceOptions] = None)
    
    @overload
    def Rule(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             disabled: Optional[bool] = None,
             name: Optional[str] = None,
             type: Optional[str] = None,
             blocking_effect: Optional[str] = None,
             content: Optional[str] = None,
             description: Optional[str] = None,
             labels: Optional[Sequence[str]] = None,
             source_file: Optional[str] = None,
             source_hash: Optional[str] = None)
    func NewRule(ctx *Context, name string, args RuleArgs, opts ...ResourceOption) (*Rule, error)
    public Rule(string name, RuleArgs args, CustomResourceOptions? opts = null)
    public Rule(String name, RuleArgs args)
    public Rule(String name, RuleArgs args, CustomResourceOptions options)
    
    type: impart:Rule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args RuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args RuleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args RuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RuleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var ruleResource = new Impart.Rule("ruleResource", new()
    {
        Disabled = false,
        Name = "string",
        Type = "string",
        BlockingEffect = "string",
        Content = "string",
        Description = "string",
        Labels = new[]
        {
            "string",
        },
        SourceFile = "string",
        SourceHash = "string",
    });
    
    example, err := impart.NewRule(ctx, "ruleResource", &impart.RuleArgs{
    	Disabled:       pulumi.Bool(false),
    	Name:           pulumi.String("string"),
    	Type:           pulumi.String("string"),
    	BlockingEffect: pulumi.String("string"),
    	Content:        pulumi.String("string"),
    	Description:    pulumi.String("string"),
    	Labels: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	SourceFile: pulumi.String("string"),
    	SourceHash: pulumi.String("string"),
    })
    
    var ruleResource = new Rule("ruleResource", RuleArgs.builder()
        .disabled(false)
        .name("string")
        .type("string")
        .blockingEffect("string")
        .content("string")
        .description("string")
        .labels("string")
        .sourceFile("string")
        .sourceHash("string")
        .build());
    
    rule_resource = impart.Rule("ruleResource",
        disabled=False,
        name="string",
        type="string",
        blocking_effect="string",
        content="string",
        description="string",
        labels=["string"],
        source_file="string",
        source_hash="string")
    
    const ruleResource = new impart.Rule("ruleResource", {
        disabled: false,
        name: "string",
        type: "string",
        blockingEffect: "string",
        content: "string",
        description: "string",
        labels: ["string"],
        sourceFile: "string",
        sourceHash: "string",
    });
    
    type: impart:Rule
    properties:
        blockingEffect: string
        content: string
        description: string
        disabled: false
        labels:
            - string
        name: string
        sourceFile: string
        sourceHash: string
        type: string
    

    Rule Resource Properties

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

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The Rule resource accepts the following input properties:

    Disabled bool
    Set true to disable the rule.
    Name string
    The name for this rule.
    Type string
    The type of the rule. Allowed values: script, recipe.
    BlockingEffect string
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    Content string
    The rule body content.
    Description string
    The description for this rule.
    Labels List<string>
    The applied labels.
    SourceFile string
    The rule source file.
    SourceHash string
    The rule source hash.
    Disabled bool
    Set true to disable the rule.
    Name string
    The name for this rule.
    Type string
    The type of the rule. Allowed values: script, recipe.
    BlockingEffect string
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    Content string
    The rule body content.
    Description string
    The description for this rule.
    Labels []string
    The applied labels.
    SourceFile string
    The rule source file.
    SourceHash string
    The rule source hash.
    disabled Boolean
    Set true to disable the rule.
    name String
    The name for this rule.
    type String
    The type of the rule. Allowed values: script, recipe.
    blockingEffect String
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content String
    The rule body content.
    description String
    The description for this rule.
    labels List<String>
    The applied labels.
    sourceFile String
    The rule source file.
    sourceHash String
    The rule source hash.
    disabled boolean
    Set true to disable the rule.
    name string
    The name for this rule.
    type string
    The type of the rule. Allowed values: script, recipe.
    blockingEffect string
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content string
    The rule body content.
    description string
    The description for this rule.
    labels string[]
    The applied labels.
    sourceFile string
    The rule source file.
    sourceHash string
    The rule source hash.
    disabled bool
    Set true to disable the rule.
    name str
    The name for this rule.
    type str
    The type of the rule. Allowed values: script, recipe.
    blocking_effect str
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content str
    The rule body content.
    description str
    The description for this rule.
    labels Sequence[str]
    The applied labels.
    source_file str
    The rule source file.
    source_hash str
    The rule source hash.
    disabled Boolean
    Set true to disable the rule.
    name String
    The name for this rule.
    type String
    The type of the rule. Allowed values: script, recipe.
    blockingEffect String
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content String
    The rule body content.
    description String
    The description for this rule.
    labels List<String>
    The applied labels.
    sourceFile String
    The rule source file.
    sourceHash String
    The rule source hash.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Rule 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 string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing Rule Resource

    Get an existing Rule 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?: RuleState, opts?: CustomResourceOptions): Rule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            blocking_effect: Optional[str] = None,
            content: Optional[str] = None,
            description: Optional[str] = None,
            disabled: Optional[bool] = None,
            labels: Optional[Sequence[str]] = None,
            name: Optional[str] = None,
            source_file: Optional[str] = None,
            source_hash: Optional[str] = None,
            type: Optional[str] = None) -> Rule
    func GetRule(ctx *Context, name string, id IDInput, state *RuleState, opts ...ResourceOption) (*Rule, error)
    public static Rule Get(string name, Input<string> id, RuleState? state, CustomResourceOptions? opts = null)
    public static Rule get(String name, Output<String> id, RuleState state, CustomResourceOptions options)
    resources:  _:    type: impart:Rule    get:      id: ${id}
    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.
    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:
    BlockingEffect string
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    Content string
    The rule body content.
    Description string
    The description for this rule.
    Disabled bool
    Set true to disable the rule.
    Labels List<string>
    The applied labels.
    Name string
    The name for this rule.
    SourceFile string
    The rule source file.
    SourceHash string
    The rule source hash.
    Type string
    The type of the rule. Allowed values: script, recipe.
    BlockingEffect string
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    Content string
    The rule body content.
    Description string
    The description for this rule.
    Disabled bool
    Set true to disable the rule.
    Labels []string
    The applied labels.
    Name string
    The name for this rule.
    SourceFile string
    The rule source file.
    SourceHash string
    The rule source hash.
    Type string
    The type of the rule. Allowed values: script, recipe.
    blockingEffect String
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content String
    The rule body content.
    description String
    The description for this rule.
    disabled Boolean
    Set true to disable the rule.
    labels List<String>
    The applied labels.
    name String
    The name for this rule.
    sourceFile String
    The rule source file.
    sourceHash String
    The rule source hash.
    type String
    The type of the rule. Allowed values: script, recipe.
    blockingEffect string
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content string
    The rule body content.
    description string
    The description for this rule.
    disabled boolean
    Set true to disable the rule.
    labels string[]
    The applied labels.
    name string
    The name for this rule.
    sourceFile string
    The rule source file.
    sourceHash string
    The rule source hash.
    type string
    The type of the rule. Allowed values: script, recipe.
    blocking_effect str
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content str
    The rule body content.
    description str
    The description for this rule.
    disabled bool
    Set true to disable the rule.
    labels Sequence[str]
    The applied labels.
    name str
    The name for this rule.
    source_file str
    The rule source file.
    source_hash str
    The rule source hash.
    type str
    The type of the rule. Allowed values: script, recipe.
    blockingEffect String
    The rule blocking effect. Allowed values: block, simulate. If not set effect will be block.
    content String
    The rule body content.
    description String
    The description for this rule.
    disabled Boolean
    Set true to disable the rule.
    labels List<String>
    The applied labels.
    name String
    The name for this rule.
    sourceFile String
    The rule source file.
    sourceHash String
    The rule source hash.
    type String
    The type of the rule. Allowed values: script, recipe.

    Package Details

    Repository
    impart impart-security/pulumi-impart
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the impart Terraform Provider.
    impart logo
    Impart Security v0.10.0 published on Tuesday, May 20, 2025 by Impart Security