runway.config package

CFNgin config.

class runway.config.BaseConfig[source]

Bases: object

Base class for configurations.

__init__(data: BaseModel, *, path: Optional[Path] = 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: Optional[Union[AbstractSet[Union[int, str]], Mapping[Union[int, str], Any]]] = None, exclude_defaults: bool = False, exclude_none: bool = False, exclude_unset: bool = True, include: Optional[Union[AbstractSet[Union[int, str]], Mapping[Union[int, str], Any]]] = 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: pathlib.Path) Optional[pathlib.Path][source]

Find a config file in the provided path.

Parameters

path – The path to search for a config file.

__new__(**kwargs)
class runway.config.CfnginConfig[source]

Bases: runway.config.BaseConfig

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_REGEX = 'runway(\\..*)?\\.(yml|yaml)'

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

EXCLUDE_LIST = ['bitbucket-pipelines.yml', 'buildspec.yml', 'docker-compose.yml']

Explicit files names to ignore when looking for config files.

__new__(**kwargs)
dump(*, by_alias: bool = False, exclude: Optional[Union[AbstractSet[Union[int, str]], Mapping[Union[int, str], Any]]] = None, exclude_defaults: bool = False, exclude_none: bool = False, exclude_unset: bool = True, include: Optional[Union[AbstractSet[Union[int, str]], Mapping[Union[int, str], Any]]] = None) str

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.

__init__(data: runway.config.models.cfngin.CfnginConfigDefinitionModel, *, path: Optional[pathlib.Path] = None, work_dir: Optional[pathlib.Path] = 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: Optional[str]

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

cfngin_bucket_region: Optional[str]

Explicit region to use for CfnginConfig.cfngin_bucket

cfngin_cache_dir: Path

Local directory to use for caching.

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.

persistent_graph_key: Optional[str] = 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.

service_role: Optional[str]

IAM role for CloudFormation to use.

stacks: List[CfnginStackDefinitionModel]

Stacks to be processed.

sys_path: Optional[Path]

Relative or absolute path to use as the work directory.

tags: Optional[Dict[str, str]]

Tags to apply to all resources.

template_indent: int

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

load() None[source]

Load config options into the current environment/session.

classmethod find_config_file(path: Optional[pathlib.Path] = None, *, exclude: Optional[List[str]] = None) List[pathlib.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.

classmethod parse_file(*, path: Optional[pathlib.Path] = None, file_path: Optional[pathlib.Path] = None, parameters: Optional[MutableMapping[str, Any]] = None, work_dir: Optional[pathlib.Path] = None, **kwargs: Any) runway.config.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.

Raises

ConfigNotFound – Provided config file was not found.

classmethod parse_obj(obj: Any, *, path: Optional[pathlib.Path] = None, work_dir: Optional[pathlib.Path] = None) runway.config.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: Optional[MutableMapping[str, Any]] = None, path: Optional[pathlib.Path] = None, skip_package_sources: bool = False, work_dir: Optional[pathlib.Path] = None) runway.config.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.

classmethod process_package_sources(raw_data: str, *, parameters: Optional[MutableMapping[str, Any]] = None, work_dir: Optional[pathlib.Path] = 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: Optional[MutableMapping[str, Any]] = 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.

class runway.config.RunwayConfig[source]

Bases: runway.config.BaseConfig

Python representation of a Runway config file.

__new__(**kwargs)
dump(*, by_alias: bool = False, exclude: Optional[Union[AbstractSet[Union[int, str]], Mapping[Union[int, str], Any]]] = None, exclude_defaults: bool = False, exclude_none: bool = False, exclude_unset: bool = True, include: Optional[Union[AbstractSet[Union[int, str]], Mapping[Union[int, str], Any]]] = None) str

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.

__init__(data: runway.config.models.runway.RunwayConfigDefinitionModel, *, path: Optional[pathlib.Path] = 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: pathlib.Path) pathlib.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: Optional[pathlib.Path] = None, file_path: Optional[pathlib.Path] = 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.

Raises
classmethod parse_obj(obj: Any, *, path: Optional[pathlib.Path] = 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.