runway.context package

Context objects.

class runway.context.CfnginContext[source]

Bases: BaseContext

CFNgin context object.

__init__(*, config: CfnginConfig | None = None, config_path: Path | None = None, deploy_environment: DeployEnvironment | None = None, force_stacks: list[str] | None = None, logger: PrefixAdaptor | RunwayLogger = <RunwayLogger runway.context._cfngin (WARNING)>, parameters: MutableMapping[str, Any] | None = None, stack_names: list[str] | None = None, work_dir: Path | None = None, **_: Any) None[source]

Instantiate class.

Parameters:
  • config – The CFNgin configuration being operated on.

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

  • 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.

  • work_dir – Working directory used by Runway.

property base_fqn: str

Return namespace sanitized for use as an S3 Bucket name.

property bucket_name: str | None

Return cfngin_bucket from config, calculated name, or None.

bucket_region: str

Region where the S3 Bucket is located.

The S3 Bucket being the Bucket configured for staging CloudFormation Templates.

config: CfnginConfig

CFNgin configuration file that has been resolved & parsed into a python object.

config_path: Path

Path to the configuration file that has been resolved, parsed and made accessible via this object.

copy() runway.context.CfnginContext[source]

Copy the contents of this object into a new instance.

env: DeployEnvironment

Deploy environment object containing information about the current deploy environment.

force_stacks: list[str]

List of stacks to force.

get_fqn(name: str | None = 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) Stack | None[source]

Get a stack by name.

Parameters:

name – Name of a Stack as defined in the config.

hook_data: dict[str, Any]

Values returned by hooks that are stored based on the data_key defined for the hook.

Returned values are only stored if a data_key was provided AND the return value is a dict or pydantic.BaseModel.

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: PrefixAdaptor | RunwayLogger

Custom logger to use when logging messages.

property mappings: dict[str, dict[str, dict[str, Any]]]

Return mappings from config.

property namespace: str

Return namespace from config.

property namespace_delimiter: str

Return namespace_delimiter from config or default.

parameters: MutableMapping[str, Any]

Parameters passed from Runway or read from a file.

property persistent_graph: Graph | None

Graph if a persistent graph is being used.

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

property persistent_graph_location: PersistentGraphLocation

Location of the persistent graph in s3.

property persistent_graph_lock_code: str | None

Code used to lock the persistent graph S3 object.

property persistent_graph_locked: bool

Check if persistent graph is locked.

property persistent_graph_tags: dict[str, str]

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: bool

Check CFNgin bucket exists and you have access.

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

property s3_client: S3Client

AWS S3 client.

set_hook_data(key: str, data: 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]

List of Stack names to operate on.

If value is falsy, all Stacks defined in the config will be operated on.

property stacks: list[Stack]

Stacks for the current action.

property stacks_dict: dict[str, Stack]

Construct a dict of {stack.fqn: Stack} for easy access to stacks.

property tags: dict[str, str]

Return tags from config.

property template_indent: int

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

property upload_to_s3: bool

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

class runway.context.RunwayContext[source]

Bases: BaseContext

Runway context object.

__init__(*, command: RunwayActionTypeDef | None = None, deploy_environment: DeployEnvironment | None = None, logger: PrefixAdaptor | RunwayLogger = <RunwayLogger runway.context._runway (WARNING)>, work_dir: Path | None = None, **_: Any) None[source]

Instantiate class.

Parameters:
  • command – Runway command/action being run.

  • deploy_environment – The current deploy environment.

  • logger – Custom logger.

  • work_dir – Working directory used by Runway.

command: RunwayActionTypeDef | None

Runway command/action being run.

copy() runway.context.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.

property no_color: bool

Whether to explicitly disable color output.

Primarily applies to IaC being wrapped by Runway.

property use_concurrent: bool

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.

Submodules