runway.module.base module

Base classes for runway modules.

class runway.module.base.RunwayModule[source]

Bases: object

Base class for Runway modules.

__init__(context: RunwayContext, *, explicitly_enabled: Optional[bool] = False, logger: RunwayLogger = <RunwayLogger runway.module.base (WARNING)>, module_root: Path, name: Optional[str] = None, options: Optional[Union[Dict[str, Any], ModuleOptions]] = None, parameters: Optional[Dict[str, Any]] = None, **_: Any) None[source]

Instantiate class.

Parameters
  • context – Runway context object for the current session.

  • explicitly_enabled – Whether or not the module is explicitly enabled. This is can be set in the event that the current environment being deployed to matches the defined environments of the module/deployment.

  • logger – Used to write logs.

  • module_root – Root path of the module.

  • name – Name of the module.

  • options – Options passed to the module class from the config as options or module_options if coming from the deployment level.

  • parameters – Values to pass to the underlying infrastructure as code tool that will alter the resulting infrastructure being deployed. Used to templatize IaC.

deploy() None[source]

Abstract method called when running deploy.

destroy() None[source]

Abstract method called when running destroy.

init() None[source]

Abstract method called when running init.

plan() None[source]

Abstract method called when running plan.

__getitem__(key: str) Any[source]

Make the object subscriptable.

Parameters

key – Attribute to get.

__new__(**kwargs)
class runway.module.base.RunwayModuleNpm[source]

Bases: runway.module.base.RunwayModule

Base class for Runway modules that use npm.

__init__(context: RunwayContext, *, explicitly_enabled: Optional[bool] = False, logger: RunwayLogger = <RunwayLogger runway.module.base (WARNING)>, module_root: Path, name: Optional[str] = None, options: Optional[Union[Dict[str, Any], ModuleOptions]] = None, parameters: Optional[Dict[str, Any]] = None, **_: Any) None[source]

Instantiate class.

Parameters
  • context – Runway context object for the current session.

  • explicitly_enabled – Whether or not the module is explicitly enabled. This is can be set in the event that the current environment being deployed to matches the defined environments of the module/deployment.

  • logger – Used to write logs.

  • module_root – Root path of the module.

  • name – Name of the module.

  • options – Options passed to the module class from the config as options or module_options if coming from the deployment level.

  • parameters – Values to pass to the underlying infrastructure as code tool that will alter the resulting infrastructure being deployed. Used to templatize IaC.

log_npm_command(command: List[str]) None[source]

Log an npm command that is going to be run.

Parameters

command – List that will be passed into a subprocess.

npm_install() None[source]

Run npm install.

__getitem__(key: str) Any

Make the object subscriptable.

Parameters

key – Attribute to get.

__new__(**kwargs)
deploy() None

Abstract method called when running deploy.

destroy() None

Abstract method called when running destroy.

init() None

Abstract method called when running init.

package_json_missing() bool[source]

Check for the existence for a package.json file in the module.

Returns

True if the file was not found.

Return type

bool

plan() None

Abstract method called when running plan.

static check_for_npm(*, logger: Union[logging.Logger, PrefixAdaptor, RunwayLogger] = <RunwayLogger runway.module.base (WARNING)>) None[source]

Ensure npm is installed and in the current path.

Parameters

logger – Optionally provide a custom logger to use.

static warn_on_boto_env_vars(env_vars: Dict[str, str], *, logger: Union[logging.Logger, PrefixAdaptor, RunwayLogger] = <RunwayLogger runway.module.base (WARNING)>) None[source]

Inform user if boto-specific environment variables are in use.

Parameters
  • env_vars – Environment variables to check.

  • logger – Optionally provide a custom logger to use.

class runway.module.base.ModuleOptions[source]

Bases: object

Base class for Runway module options.

__init__()
__new__(**kwargs)
get(name: str, default: Any = None) Any[source]

Get a value or return the default.

__eq__(other: Any) bool[source]

Assess equality.