runway.config package

CFNgin config.

class runway.config.BaseConfig(data: BaseModel, *, path: Optional[Path] = None)[source]

Bases: object

Base class for configurations.

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: Path)Optional[Path][source]

Find a config file in the provided path.

Parameters

path – The path to search for a config file.

class runway.config.CfnginConfig(data: CfnginConfigDefinitionModel, *, path: Optional[Path] = None)[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)

Instantiate class.

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

  • path – Path to the config file.

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.

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.

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.

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[Path] = None, *, exclude: Optional[List[str]] = 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.

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

Raises

ConfigNotFound – Provided config file was not found.

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

classmethod parse_raw(data: str, *, parameters: Optional[MutableMapping[str, Any]] = None, path: Optional[Path] = None, skip_package_sources: bool = False)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.

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

Process the package sources defined in a rendered config.

Parameters
  • raw_data – Raw configuration data.

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

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(data: RunwayConfigDefinitionModel, *, path: Optional[Path] = None)[source]

Bases: runway.config.BaseConfig

Python representation of a Runway config file.

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

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)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[Path] = None, file_path: Optional[Path] = None, **kwargs: Any)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[Path] = None)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.