runway.context package

Context objects.

class runway.context.CfnginContext(*, config_path: Optional[pathlib.Path] = None, config: Optional[runway.config.CfnginConfig] = None, deploy_environment: Optional[runway.core.components._deploy_environment.DeployEnvironment] = None, force_stacks: Optional[List[str]] = None, logger: Union[runway._logging.PrefixAdaptor, runway._logging.RunwayLogger] = <RunwayLogger runway.context.cfngin (WARNING)>, parameters: Optional[MutableMapping[str, Any]] = None, stack_names: Optional[List[str]] = None, **_: Any)[source]

Bases: runway.context.base.BaseContext

CFNgin context object.

Instantiate class.

Parameters
  • config_path – Path to the config file that was provided.

  • config – The CFNgin configuration being operated on.

  • deploy_environment – The current deploy environment.

  • force_stacks – A list of stacks to force work on. Used to work on locked stacks.

  • logger – Custom logger.

  • parameters – Parameters passed from Runway or read from a file.

  • stack_names – A list of stack_names to operate on. If not passed, all stacks defined in the config will be operated on.

base_fqn

Return namespace sanitized for use as an S3 Bucket name.

bucket_name

Return cfngin_bucket from config, calculated name, or None.

bucket_region: str
config: CfnginConfig
config_path: Path
copy()runway.context.cfngin.CfnginContext[source]

Copy the contents of this object into a new instance.

env: DeployEnvironment
force_stacks: List[str]
get_fqn(name: Optional[str] = None)str[source]

Return the fully qualified name of an object within this context.

If the name passed already appears to be a fully qualified name, it will be returned with no further processing.

get_stack(name: str) → Optional[runway.cfngin.stack.Stack][source]

Get a stack by name.

Parameters

name – Name of a stack to retrieve.

hook_data: Dict[str, Any]
lock_persistent_graph(lock_code: str)None[source]

Locks the persistent graph in s3.

Parameters

lock_code – The code that will be used to lock the S3 object.

Raises
logger: Union[PrefixAdaptor, RunwayLogger]
mappings

Return mappings from config.

namespace

Return namespace from config.

namespace_delimiter

Return namespace_delimiter from config or default.

parameters: MutableMapping[str, Any]
property persistent_graph

Graph if a persistent graph is being used.

Will create an “empty” object in S3 if one is not found.

persistent_graph_location

Location of the persistent graph in s3.

property persistent_graph_lock_code

Code used to lock the persistent graph S3 object.

property persistent_graph_locked

Check if persistent graph is locked.

property persistent_graph_tags

Cache of tags on the persistent graph object.

put_persistent_graph(lock_code: str)None[source]

Upload persistent graph to s3.

Parameters

lock_code (str) – The code that will be used to lock the S3 object.

Raises
property s3_bucket_verified

Check CFNgin bucket exists and you have access.

If the CFNgin bucket does not exist, will try to create one.

s3_client

AWS S3 client.

set_hook_data(key: str, data: collections.Mapping[str, Any])None[source]

Set hook data for the given key.

Parameters
  • key – The key to store the hook data in.

  • data – A dictionary of data to store, as returned from a hook.

stack_names: List[str]
stacks

Stacks for the current action.

stacks_dict

Stack} for easy access to stacks.

Type

Construct a dict of {stack.fqn

tags

Return tags from config.

template_indent

Return template_indent from config or default.

unlock_persistent_graph(lock_code: str)bool[source]

Unlocks the persistent graph in s3.

Parameters

lock_code – The code that will be used to lock the S3 object.

Raises

runway.cfngin.exceptions.PersistentGraphCannotUnlock

upload_to_s3

Check if S3 should be used for caching/persistent graph.

class runway.context.RunwayContext(*, command: Optional[str] = None, deploy_environment: Optional[DeployEnvironment] = None, logger: Union[PrefixAdaptor, RunwayLogger] = <RunwayLogger runway.context.runway (WARNING)>, **_: Any)[source]

Bases: runway.context.base.BaseContext

Runway context object.

Instantiate class.

Parameters
  • command – Runway command/action being run.

  • deploy_environment – The current deploy environment.

  • logger – Custom logger.

command: Optional[str]
copy()runway.context.runway.RunwayContext[source]

Copy the contents of this object into a new instance.

echo_detected_environment()None[source]

Print a helper note about how the environment was determined.

env: DeployEnvironment
logger: Union[PrefixAdaptor, RunwayLogger]
no_color

Whether to explicitly disable color output.

Primarily applies to IaC being wrapped by Runway.

use_concurrent

Whether to use concurrent.futures or not.

Noninteractive is required for concurrent execution to prevent weird user-input behavior.

Python 3 is required because backported futures has issues with ProcessPoolExecutor.