runway.cfngin.hooks.command module

Command hook.

class runway.cfngin.hooks.command.RunCommandResponseTypeDef(_typename, _fields=None, /, **kwargs)[source]

Bases: dict

Response from run_command.

runway.cfngin.hooks.command.run_command(*, command: Union[str, List[str]], capture: bool = False, interactive: bool = False, ignore_status: bool = False, quiet: bool = False, stdin: Optional[str] = None, env: Optional[Dict[str, str]] = None, **kwargs: Any)runway.cfngin.hooks.command.RunCommandResponseTypeDef[source]

Run a custom command as a hook.

  • command – Command(s) to run.

  • capture – If enabled, capture the command’s stdout and stderr, and return them in the hook result.

  • interactive – If enabled, allow the command to interact with stdin. Otherwise, stdin will be set to the null device.

  • ignore_status – Don’t fail the hook if the command returns a non-zero status.

  • quiet – Redirect the command’s stdout and stderr to the null device, silencing all output. Should not be enabled if capture is also enabled.

  • stdin – String to send to the stdin of the command. Implicitly disables interactive.

  • env – Dictionary of environment variable overrides for the command context. Will be merged with the current environment.

Additional keyword arguments passed to the function will be forwarded to the subprocess.Popen function. Interesting ones include: cwd and shell.


    path: runway.cfngin.hooks.command.run_command
    required: true
    enabled: true
    data_key: copy_env
      command: ['cp', 'environment.template', 'environment']
    path: runway.cfngin.hooks.command.run_command
    required: true
    enabled: true
    data_key: get_git_commit
      command: ['git', 'rev-parse', 'HEAD']
      cwd: ./my-git-repo
      capture: true
    path: runway.cfngin.hooks.command.run_command
      command: '`cd $PROJECT_DIR/project; npm install`'
        PROJECT_DIR: ./my-project
        shell: true