Built-in hooks

You can use hooks to execute actions at specific stages of stack deploy and undeploy operations. Takomo has two built-in hooks, and you can also implement your own.

In a stack configuration, you choose which type of hook to use by providing value to the type property. You also need to give a name for each hook. In addition to these two mandatory properties, each hook type may have its own set of additional properties.

Command hook

The command hook executes the specified shell command.

Properties

Here are the properties of the Command hook:

Environment variables available in the shell command

The following environment variables are available in the shell command:

Any output the hook prints to the stdout is captured and exposed to other hooks.

Examples

A command hook that runs a simple shell command:

- name: my-hook
  type: cmd
  command: echo 'hello world'

A command hook that exposes the current stack's AWS credentials to the shell command:

- name: my-another-hook
  type: cmd
  exposeStackCredentials: true
  command: aws sts get-caller-identity

Checksum hook

The checksum hook calculates a checksum from a specified directory. The checksum is calculated recursively, i.e. all files and directories under the specified directory are included in the checksum.

Properties

Here are the properties of the Checksum hook:

Examples

Calculate a checksum from a directory lambda/scripts located in the project directory.

- name: my-checksum
  type: checksum
  dir: lambda/scripts

The same as above but using the hex encoding.

- name: my-hex-checksum
  type: checksum
  dir: lambda/scripts
  encoding: hex

See also

Last updated