1. Packages
  2. Packages
  3. Formal Provider
  4. API Docs
  5. Hook
Viewing docs for Formal v1.2.2
published on Wednesday, Jul 15, 2026 by Formal
formal logo
Viewing docs for Formal v1.2.2
published on Wednesday, Jul 15, 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,
             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",
        Description = "string",
        Name = "string",
        Status = "string",
        TimeoutMs = 0,
    });
    
    example, err := formal.NewHook(ctx, "hookResource", &formal.HookArgs{
    	Code:        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"
      description = "string"
      name        = "string"
      status      = "string"
      timeout_ms  = 0
    }
    
    var hookResource = new Hook("hookResource", HookArgs.builder()
        .code("string")
        .description("string")
        .name("string")
        .status("string")
        .timeoutMs(0)
        .build());
    
    hook_resource = formal.Hook("hookResource",
        code="string",
        description="string",
        name="string",
        status="string",
        timeout_ms=0)
    
    const hookResource = new formal.Hook("hookResource", {
        code: "string",
        description: "string",
        name: "string",
        status: "string",
        timeoutMs: 0,
    });
    
    type: formal:Hook
    properties:
        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) { ... }).
    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) { ... }).
    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) { ... }).
    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) { ... }).
    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) { ... }).
    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) { ... }).
    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) { ... }).
    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,
            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:
    Code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.
    Code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.
    code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.
    code String
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.
    code string
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.
    code str
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.
    code String
    The hook implementation as JavaScript. Must be a default-exported function (for example export default function hook(input) { ... }).
    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.2
    published on Wednesday, Jul 15, 2026 by Formal

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial