runway.config package

CFNgin config.

class runway.config.BaseConfig[source]

Bases: Generic[_ModelTypeVar]

Base class for configurations.

__init__(data: _ModelTypeVar, *, path: Path | None = None) None[source]

Instantiate class.

Parameters:
  • data – The data model of the config file.

  • path – Path to the config file.

dump(*, by_alias: bool = False, exclude: set[int | str] | Mapping[int | str, Any] | None = None, exclude_defaults: bool = False, exclude_none: bool = False, exclude_unset: bool = True, include: set[int | str] | Mapping[int | str, Any] | None = None) str[source]

Dump model to a YAML string.

Parameters:
  • by_alias – Whether field aliases should be used as keys in the returned dictionary.

  • exclude – Fields to exclude from the returned dictionary.

  • exclude_defaults – Whether fields which are equal to their default values (whether set or otherwise) should be excluded from the returned dictionary.

  • exclude_none – Whether fields which are equal to None should be excluded from the returned dictionary.

  • exclude_unset – Whether fields which were not explicitly set when creating the model should be excluded from the returned dictionary.

  • include – Fields to include in the returned dictionary.

classmethod find_config_file(path: Path) Path | None[source]

Find a config file in the provided path.

Parameters:

path – The path to search for a config file.

class runway.config.CfnginConfig[source]

Bases: BaseConfig[CfnginConfigDefinitionModel]

Python representation of a CFNgin config file.

This is used internally by CFNgin to parse and validate a YAML formatted CFNgin configuration file, but can also be used in scripts to generate a CFNgin config file before handing it off to CFNgin to deploy/destroy.

Example:

from runway.cfngin.config import dump, Config, Stack

vpc = Stack({
    "name": "vpc",
    "class_path": "blueprints.VPC"})

config = Config()
config.namespace = "prod"
config.stacks = [vpc]

print dump(config)
EXCLUDE_LIST: ClassVar[list[str]] = []

Explicit files names to ignore when looking for config files.

EXCLUDE_REGEX: ClassVar[str] = '(?x)^(bitbucket-pipelines|buildspec|docker-compose|runway)(\\..*)?\\.(yml|yaml)'

Regex for file names to exclude when looking for config files.

__init__(data: CfnginConfigDefinitionModel, *, path: Path | None = None, work_dir: Path | None = None) None[source]

Instantiate class.

Parameters:
  • data – The data model of the config file.

  • path – Path to the config file.

  • work_dir – Working directory.

cfngin_bucket: str | None

Bucket to use for CFNgin resources. (e.g. CloudFormation templates). May be an empty string.

cfngin_bucket_region: str | None

Explicit region to use for CfnginConfig.cfngin_bucket

cfngin_cache_dir: Path

Local directory to use for caching.

classmethod find_config_file(path: Path | None = None, *, exclude: list[str] | None = None) list[Path][source]

Find a config file in the provided path.

Parameters:
  • path – The path to search for a config file.

  • exclude – List of file names to exclude. This list is appended to the global exclude list.

Raises:
  • ConfigNotFound – Could not find a config file in the provided path.

  • ValueError – More than one config file found in the provided path.

load() None[source]

Load config options into the current environment/session.

log_formats: dict[str, str]

Custom formatting for log messages.

lookups: dict[str, str]

Register custom lookups.

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

Mappings that will be added to all stacks.

namespace: str

Namespace to prepend to everything.

namespace_delimiter: str

Character used to separate CfnginConfig.namespace and anything it prepends.

package_sources: CfnginPackageSourcesDefinitionModel

Remote source locations.

classmethod parse_file(*, path: Path | None = None, file_path: Path | None = None, parameters: MutableMapping[str, Any] | None = None, work_dir: Path | None = None, **kwargs: Any) CfnginConfig[source]

Parse a YAML file to create a config object.

Parameters:
  • path – The path to search for a config file.

  • file_path – Exact path to a file to parse.

  • parameters – Values to use when resolving a raw config.

  • work_dir – Explicit working directory.

  • **kwargs – Arbitrary keyword arguments.

Raises:

ConfigNotFound – Provided config file was not found.

classmethod parse_obj(obj: Any, *, path: Path | None = None, work_dir: Path | None = None) CfnginConfig[source]

Parse a python object.

Parameters:
  • obj – A python object to parse as a CFNgin config.

  • path – The path to the config file that was parsed into the object.

  • work_dir – Working directory.

classmethod parse_raw(data: str, *, parameters: MutableMapping[str, Any] | None = None, path: Path | None = None, skip_package_sources: bool = False, work_dir: Path | None = None) CfnginConfig[source]

Parse raw data.

Parameters:
  • data – The raw data to parse.

  • parameters – Values to use when resolving a raw config.

  • path – The path to search for a config file.

  • skip_package_sources – Skip processing package sources.

  • work_dir – Explicit working directory.

persistent_graph_key: str | None = None

S3 object key were the persistent graph is stored.

post_deploy: list[CfnginHookDefinitionModel]

Hooks to run after a deploy action.

post_destroy: list[CfnginHookDefinitionModel]

Hooks to run after a destroy action.

pre_deploy: list[CfnginHookDefinitionModel]

Hooks to run before a deploy action.

pre_destroy: list[CfnginHookDefinitionModel]

Hooks to run before a destroy action.

classmethod process_package_sources(raw_data: str, *, parameters: MutableMapping[str, Any] | None = None, work_dir: Path | None = None) str[source]

Process the package sources defined in a rendered config.

Parameters:
  • raw_data – Raw configuration data.

  • cache_dir – Directory to use when caching remote sources.

  • parameters – Values to use when resolving a raw config.

  • work_dir – Explicit working directory.

static resolve_raw_data(raw_data: str, *, parameters: MutableMapping[str, Any] | None = None) str[source]

Resolve raw data.

Parameters:
  • raw_data – Raw configuration data.

  • parameters – Values to use when resolving a raw config.

Raises:

MissingEnvironment – A value required by the config was not provided in parameters.

service_role: str | None

IAM role for CloudFormation to use.

stacks: list[CfnginStackDefinitionModel]

Stacks to be processed.

sys_path: Path | None

Relative or absolute path to use as the work directory.

tags: dict[str, str] | None

Tags to apply to all resources.

template_indent: int

Spaces to use per-indent level when outputting a template to json.

class runway.config.RunwayConfig[source]

Bases: BaseConfig[RunwayConfigDefinitionModel]

Python representation of a Runway config file.

__init__(data: RunwayConfigDefinitionModel, *, path: Path | None = None) None[source]

Instantiate class.

Parameters:
  • data – The data model of the config file.

  • path – Path to the config file.

classmethod find_config_file(path: Path) Path[source]

Find a config file in the provided path.

Parameters:

path – The path to search for a config file.

Raises:
  • ConfigNotFound – Could not find a config file in the provided path.

  • ValueError – More than one config file found in the provided path.

classmethod parse_file(*, path: Path | None = None, file_path: Path | None = None, **kwargs: Any) runway.config.RunwayConfig[source]

Parse a YAML file to create a config object.

Parameters:
  • path – The path to search for a config file.

  • file_path – Exact path to a file to parse.

  • **kwargs – Arbitrary keyword arguments.

Raises:
classmethod parse_obj(obj: Any, *, path: Path | None = None) runway.config.RunwayConfig[source]

Parse a python object into a config object.

Parameters:
  • obj – The object to be parsed.

  • path – Path to the file the object was parsed from.

Subpackages