1. Packages
  2. Impart Security
  3. API Docs
  4. RuleScript
Impart Security v0.9.0 published on Friday, Mar 21, 2025 by Impart Security

impart.RuleScript

Explore with Pulumi AI

Manage a rule script.

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.RuleScript("example", {
    name: "example",
    disabled: false,
    description: "Rule description",
    sourceFile: `${path.module}/rule.js`,
    sourceHash: "<sha256 hash for the source_file content>",
    blockingEffect: "block",
});
// Create a new rule script with content
const exampleContent = new impart.RuleScript("exampleContent", {
    name: "example",
    disabled: false,
    description: "Rule description",
    content: fs.readFileSync(`${path.module}/rule.js`, "utf8"),
    blockingEffect: "block",
});
Copy
import pulumi
import pulumi_impart as impart

# Create a new rule script
example = impart.RuleScript("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")
# Create a new rule script with content
example_content = impart.RuleScript("exampleContent",
    name="example",
    disabled=False,
    description="Rule description",
    content=(lambda path: open(path).read())(f"{path['module']}/rule.js"),
    blocking_effect="block")
Copy
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.NewRuleScript(ctx, "example", &impart.RuleScriptArgs{
			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"),
		})
		if err != nil {
			return err
		}
		// Create a new rule script with content
		_, err = impart.NewRuleScript(ctx, "exampleContent", &impart.RuleScriptArgs{
			Name:           pulumi.String("example"),
			Disabled:       pulumi.Bool(false),
			Description:    pulumi.String("Rule description"),
			Content:        pulumi.String(readFileOrPanic(fmt.Sprintf("%v/rule.js", path.Module))),
			BlockingEffect: pulumi.String("block"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
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.RuleScript("example", new()
    {
        Name = "example",
        Disabled = false,
        Description = "Rule description",
        SourceFile = $"{path.Module}/rule.js",
        SourceHash = "<sha256 hash for the source_file content>",
        BlockingEffect = "block",
    });

    // Create a new rule script with content
    var exampleContent = new Impart.RuleScript("exampleContent", new()
    {
        Name = "example",
        Disabled = false,
        Description = "Rule description",
        Content = File.ReadAllText($"{path.Module}/rule.js"),
        BlockingEffect = "block",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.impart.RuleScript;
import com.pulumi.impart.RuleScriptArgs;
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 RuleScript("example", RuleScriptArgs.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")
            .build());

        // Create a new rule script with content
        var exampleContent = new RuleScript("exampleContent", RuleScriptArgs.builder()
            .name("example")
            .disabled(false)
            .description("Rule description")
            .content(Files.readString(Paths.get(String.format("%s/rule.js", path.module()))))
            .blockingEffect("block")
            .build());

    }
}
Copy
resources:
  # Create a new rule script
  example:
    type: impart:RuleScript
    properties:
      name: example
      disabled: false
      description: Rule description
      sourceFile: ${path.module}/rule.js
      sourceHash: <sha256 hash for the source_file content>
      blockingEffect: block
  # Create a new rule script with content
  exampleContent:
    type: impart:RuleScript
    properties:
      name: example
      disabled: false
      description: Rule description
      content:
        fn::readFile: ${path.module}/rule.js
      blockingEffect: block
Copy

Create RuleScript Resource

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

Constructor syntax

new RuleScript(name: string, args: RuleScriptArgs, opts?: CustomResourceOptions);
@overload
def RuleScript(resource_name: str,
               args: RuleScriptArgs,
               opts: Optional[ResourceOptions] = None)

@overload
def RuleScript(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               disabled: Optional[bool] = None,
               name: 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 NewRuleScript(ctx *Context, name string, args RuleScriptArgs, opts ...ResourceOption) (*RuleScript, error)
public RuleScript(string name, RuleScriptArgs args, CustomResourceOptions? opts = null)
public RuleScript(String name, RuleScriptArgs args)
public RuleScript(String name, RuleScriptArgs args, CustomResourceOptions options)
type: impart:RuleScript
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. RuleScriptArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. RuleScriptArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. RuleScriptArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. RuleScriptArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. RuleScriptArgs
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 ruleScriptResource = new Impart.RuleScript("ruleScriptResource", new()
{
    Disabled = false,
    Name = "string",
    BlockingEffect = "string",
    Content = "string",
    Description = "string",
    Labels = new[]
    {
        "string",
    },
    SourceFile = "string",
    SourceHash = "string",
});
Copy
example, err := impart.NewRuleScript(ctx, "ruleScriptResource", &impart.RuleScriptArgs{
	Disabled:       pulumi.Bool(false),
	Name:           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"),
})
Copy
var ruleScriptResource = new RuleScript("ruleScriptResource", RuleScriptArgs.builder()
    .disabled(false)
    .name("string")
    .blockingEffect("string")
    .content("string")
    .description("string")
    .labels("string")
    .sourceFile("string")
    .sourceHash("string")
    .build());
Copy
rule_script_resource = impart.RuleScript("ruleScriptResource",
    disabled=False,
    name="string",
    blocking_effect="string",
    content="string",
    description="string",
    labels=["string"],
    source_file="string",
    source_hash="string")
Copy
const ruleScriptResource = new impart.RuleScript("ruleScriptResource", {
    disabled: false,
    name: "string",
    blockingEffect: "string",
    content: "string",
    description: "string",
    labels: ["string"],
    sourceFile: "string",
    sourceHash: "string",
});
Copy
type: impart:RuleScript
properties:
    blockingEffect: string
    content: string
    description: string
    disabled: false
    labels:
        - string
    name: string
    sourceFile: string
    sourceHash: string
Copy

RuleScript 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 RuleScript resource accepts the following input properties:

Disabled This property is required. bool
Set true to disable the rule script.
Name This property is required. string
The name for this rule script.
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 script.
Labels List<string>
The applied labels.
SourceFile string
The rule source file.
SourceHash string
The rule source hash.
Disabled This property is required. bool
Set true to disable the rule script.
Name This property is required. string
The name for this rule script.
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 script.
Labels []string
The applied labels.
SourceFile string
The rule source file.
SourceHash string
The rule source hash.
disabled This property is required. Boolean
Set true to disable the rule script.
name This property is required. String
The name for this rule script.
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 script.
labels List<String>
The applied labels.
sourceFile String
The rule source file.
sourceHash String
The rule source hash.
disabled This property is required. boolean
Set true to disable the rule script.
name This property is required. string
The name for this rule script.
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 script.
labels string[]
The applied labels.
sourceFile string
The rule source file.
sourceHash string
The rule source hash.
disabled This property is required. bool
Set true to disable the rule script.
name This property is required. str
The name for this rule script.
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 script.
labels Sequence[str]
The applied labels.
source_file str
The rule source file.
source_hash str
The rule source hash.
disabled This property is required. Boolean
Set true to disable the rule script.
name This property is required. String
The name for this rule script.
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 script.
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 RuleScript 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 RuleScript Resource

Get an existing RuleScript 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?: RuleScriptState, opts?: CustomResourceOptions): RuleScript
@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) -> RuleScript
func GetRuleScript(ctx *Context, name string, id IDInput, state *RuleScriptState, opts ...ResourceOption) (*RuleScript, error)
public static RuleScript Get(string name, Input<string> id, RuleScriptState? state, CustomResourceOptions? opts = null)
public static RuleScript get(String name, Output<String> id, RuleScriptState state, CustomResourceOptions options)
resources:  _:    type: impart:RuleScript    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 script.
Disabled bool
Set true to disable the rule script.
Labels List<string>
The applied labels.
Name string
The name for this rule script.
SourceFile string
The rule source file.
SourceHash string
The rule source hash.
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 script.
Disabled bool
Set true to disable the rule script.
Labels []string
The applied labels.
Name string
The name for this rule script.
SourceFile string
The rule source file.
SourceHash string
The rule source hash.
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 script.
disabled Boolean
Set true to disable the rule script.
labels List<String>
The applied labels.
name String
The name for this rule script.
sourceFile String
The rule source file.
sourceHash String
The rule source hash.
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 script.
disabled boolean
Set true to disable the rule script.
labels string[]
The applied labels.
name string
The name for this rule script.
sourceFile string
The rule source file.
sourceHash string
The rule source hash.
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 script.
disabled bool
Set true to disable the rule script.
labels Sequence[str]
The applied labels.
name str
The name for this rule script.
source_file str
The rule source file.
source_hash str
The rule source hash.
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 script.
disabled Boolean
Set true to disable the rule script.
labels List<String>
The applied labels.
name String
The name for this rule script.
sourceFile String
The rule source file.
sourceHash String
The rule source hash.

Package Details

Repository
impart impart-security/pulumi-impart
License
Apache-2.0
Notes
This Pulumi package is based on the impart Terraform Provider.