runway.cfngin.hooks.base module

Base class for CFNgin hooks.

class runway.cfngin.hooks.base.Hook(context, provider, **kwargs)[source]

Bases: object

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.

Type

MutableMap

blueprint

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

Type

Optional[Blueprint]

context

Context instance. (passed in by CFNgin)

Type

Context

provider

Provider instance. (passed in by CFNgin)

Type

BaseProvider

stack

Stack object if the hook deploys a stack.

Type

Optional[Stack]

stack_name

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

Type

str

Instantiate class.

Parameters
property tags

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

Returns

troposphere.Tags

generate_stack(**kwargs)[source]

Create a CFNgin Stack object.

Returns

Stack

get_template_description(suffix=None)[source]

Generate a template description.

Parameters

suffix (Optional[str]) – Suffix to append to the end of a CloudFormation template description.

Returns

CloudFormation template description.

Return type

str

deploy_stack(stack=None, wait=False)[source]

Deploy a stack.

Parameters
  • stack (Optional[Stack]) – A stack to act on.

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

Returns

Ending status of the stack.

Return type

Status

destroy_stack(stack=None, wait=None)[source]

Destroy a stack.

Parameters
  • stack (Optional[Stack]) – A stack to act on.

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

Returns

Ending status of the stack.

Return type

Status

post_deploy()[source]

Run during the post_deploy stage.

post_destroy()[source]

Run during the post_destroy stage.

pre_deploy()[source]

Run during the pre_deploy stage.

pre_destroy()[source]

Run during the pre_destroy stage.

class runway.cfngin.hooks.base.HookBuildAction(context, provider)[source]

Bases: runway.cfngin.actions.build.Action

Build action that can be used from hooks.

Instantiate class.

Parameters
property provider

Override the inherited property to return the local provider.

build_provider(stack)[source]

Override the inherited method to always return local provider.

run(**kwargs)[source]

Run the action for one stack.

class runway.cfngin.hooks.base.HookDestroyAction(context, provider)[source]

Bases: runway.cfngin.hooks.base.HookBuildAction

Destroy action that can be used from hooks.

Instantiate class.

Parameters
run(**kwargs)[source]

Run the action for one stack.

class runway.cfngin.hooks.base.HookStackDefinition(name, **kwargs)[source]

Bases: collections.UserDict, object

Stack definition for use in hooks to avoid cyclic imports.

Instantiate class.