1. Registry
  2. Packages
  3. Formal Provider
  4. API Docs
  5. Hook
Viewing docs for Formal v1.2.4
published on Saturday, Aug 8, 2026 by Formal
formal logo
Viewing docs for Formal v1.2.4
published on Saturday, Aug 8, 2026 by Formal

    Hooks are JavaScript functions evaluated during policy decisions. Policies reference hooks as input.hooks.<name>.

    Create Hook Resource

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

    Constructor syntax

    new Hook(name: string, args: HookArgs, opts?: CustomResourceOptions);
    @overload
    def Hook(resource_name: str,
             args: HookArgs,
             opts: Optional[ResourceOptions] = None)
    
    @overload
    def Hook(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             code: Optional[str] = None,
             allowlisted_environment_variables: Optional[Sequence[str]] = None,
             allowlisted_network_hosts: Optional[Sequence[str]] = None,
             description: Optional[str] = None,
             name: Optional[str] = None,
             status: Optional[str] = None,
             timeout_ms: Optional[int] = None)
    func NewHook(ctx *Context, name string, args HookArgs, opts ...ResourceOption) (*Hook, error)
    public Hook(string name, HookArgs args, CustomResourceOptions? opts = null)
    public Hook(String name, HookArgs args)
    public Hook(String name, HookArgs args, CustomResourceOptions options)
    
    type: formal:Hook
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "formal_hook" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args HookArgs
    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 HookArgs
    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 HookArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args HookArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args HookArgs
    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 hookResource = new Pulumi.Hook("hookResource", new()
    {
        Code = "string",
        AllowlistedEnvironmentVariables = new[]
        {
            "string",
        },
        AllowlistedNetworkHosts = new[]
        {
            "string",
        },
        Description = "string",
        Name = "string",
        Status = "string",
        TimeoutMs = 0,
    });
    
    example, err := formal.NewHook(ctx, "hookResource", &formal.HookArgs{
    	Code: pulumi.String("string"),
    	AllowlistedEnvironmentVariables: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	AllowlistedNetworkHosts: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Description: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    	Status:      pulumi.String("string"),
    	TimeoutMs:   pulumi.Int(0),
    })
    
    resource "formal_hook" "hookResource" {
      lifecycle {
        create_before_destroy = true
      }
      code                              = "string"
      allowlisted_environment_variables = ["string"]
      allowlisted_network_hosts         = ["string"]
      description                       = "string"
      name                              = "string"
      status                            = "string"
      timeout_ms                        = 0
    }
    
    var hookResource = new Hook("hookResource", HookArgs.builder()
        .code("string")
        .allowlistedEnvironmentVariables("string")
        .allowlistedNetworkHosts("string")
        .description("string")
        .name("string")
        .status("string")
        .timeoutMs(0)
        .build());
    
    hook_resource = formal.Hook("hookResource",
        code="string",
        allowlisted_environment_variables=["string"],
        allowlisted_network_hosts=["string"],
        description="string",
        name="string",
        status="string",
        timeout_ms=0)
    
    const hookResource = new formal.Hook("hookResource", {
        code: "string",
        allowlistedEnvironmentVariables: ["string"],
        allowlistedNetworkHosts: ["string"],
        description: "string",
        name: "string",
        status: "string",
        timeoutMs: 0,
    });
    
    type: formal:Hook
    properties:
        allowlistedEnvironmentVariables:
            - string
        allowlistedNetworkHosts:
            - string
        code: string
        description: string
        name: string
        status: string
        timeoutMs: 0
    

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

    Code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    AllowlistedEnvironmentVariables List<string>
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    AllowlistedNetworkHosts List<string>
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    Description string
    The hook description.
    Name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    Status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    TimeoutMs int
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    Code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    AllowlistedEnvironmentVariables []string
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    AllowlistedNetworkHosts []string
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    Description string
    The hook description.
    Name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    Status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    TimeoutMs int
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    allowlisted_environment_variables list(string)
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlisted_network_hosts list(string)
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    description string
    The hook description.
    name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeout_ms number
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    code String
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    allowlistedEnvironmentVariables List<String>
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlistedNetworkHosts List<String>
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    description String
    The hook description.
    name String
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status String
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeoutMs Integer
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    allowlistedEnvironmentVariables string[]
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlistedNetworkHosts string[]
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    description string
    The hook description.
    name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeoutMs number
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    code str
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    allowlisted_environment_variables Sequence[str]
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlisted_network_hosts Sequence[str]
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    description str
    The hook description.
    name str
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status str
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeout_ms int
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    code String
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    allowlistedEnvironmentVariables List<String>
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlistedNetworkHosts List<String>
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    description String
    The hook description.
    name String
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status String
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeoutMs Number
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.

    Outputs

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

    CreatedAt string
    When the hook was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    UpdatedAt string
    When the hook was last updated.
    CreatedAt string
    When the hook was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    UpdatedAt string
    When the hook was last updated.
    created_at string
    When the hook was created.
    id string
    The provider-assigned unique ID for this managed resource.
    updated_at string
    When the hook was last updated.
    createdAt String
    When the hook was created.
    id String
    The provider-assigned unique ID for this managed resource.
    updatedAt String
    When the hook was last updated.
    createdAt string
    When the hook was created.
    id string
    The provider-assigned unique ID for this managed resource.
    updatedAt string
    When the hook was last updated.
    created_at str
    When the hook was created.
    id str
    The provider-assigned unique ID for this managed resource.
    updated_at str
    When the hook was last updated.
    createdAt String
    When the hook was created.
    id String
    The provider-assigned unique ID for this managed resource.
    updatedAt String
    When the hook was last updated.

    Look up Existing Hook Resource

    Get an existing Hook 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?: HookState, opts?: CustomResourceOptions): Hook
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            allowlisted_environment_variables: Optional[Sequence[str]] = None,
            allowlisted_network_hosts: Optional[Sequence[str]] = None,
            code: Optional[str] = None,
            created_at: Optional[str] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            status: Optional[str] = None,
            timeout_ms: Optional[int] = None,
            updated_at: Optional[str] = None) -> Hook
    func GetHook(ctx *Context, name string, id IDInput, state *HookState, opts ...ResourceOption) (*Hook, error)
    public static Hook Get(string name, Input<string> id, HookState? state, CustomResourceOptions? opts = null)
    public static Hook get(String name, Output<String> id, HookState state, CustomResourceOptions options)
    resources:  _:    type: formal:Hook    get:      id: ${id}
    import {
      to = formal_hook.example
      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:
    AllowlistedEnvironmentVariables List<string>
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    AllowlistedNetworkHosts List<string>
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    Code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    CreatedAt string
    When the hook was created.
    Description string
    The hook description.
    Name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    Status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    TimeoutMs int
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    UpdatedAt string
    When the hook was last updated.
    AllowlistedEnvironmentVariables []string
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    AllowlistedNetworkHosts []string
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    Code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    CreatedAt string
    When the hook was created.
    Description string
    The hook description.
    Name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    Status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    TimeoutMs int
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    UpdatedAt string
    When the hook was last updated.
    allowlisted_environment_variables list(string)
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlisted_network_hosts list(string)
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    created_at string
    When the hook was created.
    description string
    The hook description.
    name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeout_ms number
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    updated_at string
    When the hook was last updated.
    allowlistedEnvironmentVariables List<String>
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlistedNetworkHosts List<String>
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    code String
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    createdAt String
    When the hook was created.
    description String
    The hook description.
    name String
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status String
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeoutMs Integer
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    updatedAt String
    When the hook was last updated.
    allowlistedEnvironmentVariables string[]
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlistedNetworkHosts string[]
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    createdAt string
    When the hook was created.
    description string
    The hook description.
    name string
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status string
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeoutMs number
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    updatedAt string
    When the hook was last updated.
    allowlisted_environment_variables Sequence[str]
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlisted_network_hosts Sequence[str]
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    code str
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    created_at str
    When the hook was created.
    description str
    The hook description.
    name str
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status str
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeout_ms int
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    updated_at str
    When the hook was last updated.
    allowlistedEnvironmentVariables List<String>
    Names of process environment variables the hook may read via its second env argument at evaluation time. Each name must match ^[A-Za-z_][A-Za-z0-9_]*$. Variables that are unset on the connector or desktop process are omitted from env.
    allowlistedNetworkHosts List<String>
    Hostnames, IP addresses, and CIDR ranges the hook may contact at evaluation time. Schemes, paths, and ports are not accepted. All ports on each host are allowed.
    code String
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input, env) { ... }). The optional second argument receives allowlisted process environment variables.
    createdAt String
    When the hook was created.
    description String
    The hook description.
    name String
    The name of the hook. Must be unique within the organization and match ^[A-Za-z_][A-Za-z0-9_]*$. Policies reference this name as input.hooks.<name>.
    status String
    The hook status. Accepted values are active and draft. Only active hooks can be referenced by policies.
    timeoutMs Number
    Maximum time in milliseconds the hook may run during policy evaluation. Must be between 1 and 60000.
    updatedAt String
    When the hook was last updated.

    Package Details

    Repository
    formal formalco/pulumi-formal
    License
    MPL-2.0
    Notes
    This Pulumi package is based on the formal Terraform Provider.
    formal logo
    Viewing docs for Formal v1.2.4
    published on Saturday, Aug 8, 2026 by Formal

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial