runway.cfngin.hooks.base module

Base class for CFNgin hooks.

class runway.cfngin.hooks.base.Hook[source]

Bases: CfnginHookProtocol

Base class for hooks.

Not all hooks need to be classes and not all classes need to be hooks.

args

Keyword arguments passed to the hook, loaded into a MutableMap object.

blueprint

Blueprint generated by the hook if it will be deploying a stack.

Type:

Blueprint | None

context

Context instance. (passed in by CFNgin)

Type:

CfnginContext

provider Provider instance.
Type:

passed in by CFNgin

stack

Stack object if the hook deploys a stack.

Type:

Stack | None

stack_name

Name of the stack created by the hook if a stack is to be created.

Type:

str

ARGS_PARSER

Class used to parse arguments passed to the hook.

alias of HookArgsBaseModel

__init__(context: CfnginContext, provider: Provider, **kwargs: Any) None[source]

Instantiate class.

Parameters:
  • context – Context instance. (passed in by CFNgin)

  • provider – Provider instance. (passed in by CFNgin)

  • **kwargs – Arbitrary keyword arguments.

deploy_stack(stack: Stack | None = None, wait: bool = False) Status[source]

Deploy a stack.

Parameters:
  • stack – A stack to act on.

  • wait – Wither to wait for the stack to complete before returning.

Returns:

Ending status of the stack.

destroy_stack(stack: Stack | None = None, wait: bool = False) Status[source]

Destroy a stack.

Parameters:
  • stack – A stack to act on.

  • wait – Wither to wait for the stack to complete before returning.

Returns:

Ending status of the stack.

generate_stack(**kwargs: Any) Stack[source]

Create a CFNgin Stack object.

get_template_description(suffix: str | None = None) str[source]

Generate a template description.

Parameters:

suffix – Suffix to append to the end of a CloudFormation template description.

post_deploy() Any[source]

Run during the post_deploy stage.

post_destroy() Any[source]

Run during the post_destroy stage.

pre_deploy() Any[source]

Run during the pre_deploy stage.

pre_destroy() Any[source]

Run during the pre_destroy stage.

property tags: Tags

Return tags that should be applied to any resource being created.

pydantic model runway.cfngin.hooks.base.HookArgsBaseModel[source]

Bases: BaseModel

Base model for hook args.

Show JSON schema
{
   "title": "HookArgsBaseModel",
   "description": "Base model for hook args.",
   "type": "object",
   "properties": {
      "tags": {
         "additionalProperties": {
            "type": "string"
         },
         "default": {},
         "title": "Tags",
         "type": "object"
      }
   }
}

field tags: dict[str, str] = {}
class runway.cfngin.hooks.base.HookDeployAction[source]

Bases: Action

Deploy action that can be used from hooks.

__init__(context: CfnginContext, provider: Provider) None[source]

Instantiate class.

Parameters:
  • context – The context for the current run.

  • provider – The provider instance.

build_provider() Provider[source]

Override the inherited method to always return local provider.

property provider: Provider

Override the inherited property to return the local provider.

run(**kwargs: Any) Status[source]

Run the action for one stack.

class runway.cfngin.hooks.base.HookDestroyAction[source]

Bases: HookDeployAction

Destroy action that can be used from hooks.

run(**kwargs: Any) Status[source]

Run the action for one stack.