published on Wednesday, Jul 15, 2026 by Formal
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)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 asinput.hooks.<name>. - Status string
- The hook status. Accepted values are
activeanddraft. 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 asinput.hooks.<name>. - Status string
- The hook status. Accepted values are
activeanddraft. 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 asinput.hooks.<name>. - status string
- The hook status. Accepted values are
activeanddraft. 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 asinput.hooks.<name>. - status String
- The hook status. Accepted values are
activeanddraft. Only active hooks can be referenced by policies. - timeout
Ms 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 asinput.hooks.<name>. - status string
- The hook status. Accepted values are
activeanddraft. 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 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 asinput.hooks.<name>. - status str
- The hook status. Accepted values are
activeanddraft. 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 asinput.hooks.<name>. - status String
- The hook status. Accepted values are
activeanddraft. 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the Hook resource produces the following output properties:
- 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.
- 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.
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) -> Hookfunc 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.
- 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 asinput.hooks.<name>. - Status string
- The hook status. Accepted values are
activeanddraft. 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 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 asinput.hooks.<name>. - Status string
- The hook status. Accepted values are
activeanddraft. 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 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 asinput.hooks.<name>. - status string
- The hook status. Accepted values are
activeanddraft. 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) { ... }). - 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 asinput.hooks.<name>. - status String
- The hook status. Accepted values are
activeanddraft. Only active hooks can be referenced by policies. - timeout
Ms Integer - 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) { ... }). - 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 asinput.hooks.<name>. - status string
- The hook status. Accepted values are
activeanddraft. 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 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 asinput.hooks.<name>. - status str
- The hook status. Accepted values are
activeanddraft. 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) { ... }). - 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 asinput.hooks.<name>. - status String
- The hook status. Accepted values are
activeanddraft. 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.
Package Details
- Repository
- formal formalco/pulumi-formal
- License
- MPL-2.0
- Notes
- This Pulumi package is based on the
formalTerraform Provider.
published on Wednesday, Jul 15, 2026 by Formal