runway.core.components package

Core Runway components.

class runway.core.components.DeployEnvironment[source]

Bases: runway.mixins.DelCachedPropMixin

Runway deploy environment.

__init__(*, environ: Optional[Dict[str, str]] = None, explicit_name: Optional[str] = None, ignore_git_branch: bool = False, root_dir: Optional[pathlib.Path] = None) None[source]

Instantiate class.

Parameters
  • environ – Environment variables.

  • explicit_name – Explicitly provide the deploy environment name.

  • ignore_git_branch – Ignore the git branch when determining the deploy environment name.

  • root_dir – Root directory of the project.

property aws_credentials: runway.type_defs.EnvVarsAwsCredentialsTypeDef

Get AWS credentials from environment variables.

property aws_profile: Optional[str]

Get AWS profile from environment variables.

property aws_region: str

Get AWS region from environment variables.

property branch_name: Optional[str]

Git branch name.

property ci: bool

Return CI status.

Returns

bool

property debug: bool

Get debug setting from the environment.

__new__(**kwargs)
property ignore_git_branch: bool

Whether to ignore git branch when determining name.

property max_concurrent_cfngin_stacks: int

Max number of CFNgin stacks that can be deployed concurrently.

This property can be set by exporting RUNWAY_MAX_CONCURRENT_CFNGIN_STACKS. If no value is specified, the value will be constrained based on the underlying graph.

Returns

Value from environment variable or 0.

property max_concurrent_modules: int

Max number of modules that can be deployed to concurrently.

This property can be set by exporting RUNWAY_MAX_CONCURRENT_MODULES. If no value is specified, min(61, os.cpu_count()) is used.

On Windows, this must be equal to or lower than 61.

IMPORTANT: When using parallel_regions and child_modules together, please consider the nature of their relationship when manually setting this value. (parallel_regions * child_modules)

Returns

Value from environment variable or min(61, os.cpu_count())

property max_concurrent_regions: int

Max number of regions that can be deployed to concurrently.

This property can be set by exporting RUNWAY_MAX_CONCURRENT_REGIONS. If no value is specified, min(61, os.cpu_count()) is used.

On Windows, this must be equal to or lower than 61.

IMPORTANT: When using parallel_regions and child_modules together, please consider the nature of their relationship when manually setting this value. (parallel_regions * child_modules)

Returns

Value from environment variable or min(61, os.cpu_count())

property name: str

Deploy environment name.

property verbose: bool

Get verbose setting from the environment.

copy() runway.core.components._deploy_environment.DeployEnvironment[source]

Copy the contents of this object into a new instance.

Returns

New instance with the same contents.

Return type

DeployEnvironment

log_name() None[source]

Output name to log.

class runway.core.components.Deployment[source]

Bases: object

Runway deployment.

__init__(context: RunwayContext, definition: RunwayDeploymentDefinition, future: Optional[RunwayFutureDefinitionModel] = None, variables: Optional[RunwayVariablesDefinition] = None) None[source]

Instantiate class.

Parameters
  • context – Runway context object.

  • definition – A single deployment definition.

  • future – Future functionality configuration.

  • variables – Runway variables.

property assume_role_config: Dict[str, Union[bool, int, str]]

Parse the definition to get assume role arguments.

property env_vars_config: Dict[str, str]

Parse the definition to get the correct env_vars configuration.

property regions: List[str]

List of regions this deployment is associated with.

property use_async: bool

Whether to use asynchronous method.

deploy() None[source]

Deploy the deployment.

High level method for running a deployment.

destroy() None[source]

Destroy the deployment.

High level method for running a deployment.

init() None[source]

Initialize/bootstrap deployment.

High level method for running a deployment.

plan() None[source]

Plan for the next deploy of the deployment.

High level method for running a deployment.

run(action: RunwayActionTypeDef, region: str) None[source]

Run a single deployment in a single region.

Low level API access to run a deployment object.

Parameters
  • action – Action to run (deploy, destroy, plan, etc.)

  • region – AWS region to run in.

validate_account_credentials(context: Optional[RunwayContext] = None) None[source]

Exit if requested deployment account doesn’t match credentials.

Parameters

context – Context object.

Raises

SystemExit – AWS Account associated with the current credentials did not match the defined criteria.

classmethod run_list(action: RunwayActionTypeDef, context: RunwayContext, deployments: List[RunwayDeploymentDefinition], future: RunwayFutureDefinitionModel, variables: RunwayVariablesDefinition) None[source]

Run a list of deployments.

Parameters
  • action – Name of action to run.

  • context – Runway context.

  • deployments – List of deployments to run.

  • future – Future definition.

  • variables – Runway variables for lookup resolution.

__getitem__(name: str) Any[source]

Make the object subscriptable.

Parameters

name – Attribute to get.

__new__(**kwargs)
class runway.core.components.Module[source]

Bases: object

Runway module.

__init__(context: RunwayContext, definition: RunwayModuleDefinition, deployment: RunwayDeploymentDefinition = None, future: RunwayFutureDefinitionModel = None, variables: RunwayVariablesDefinition = None) None[source]

Instantiate class.

Parameters
  • context – Runway context object.

  • definition – A single module definition.

  • deployment – Deployment that this module is a part of.

  • future – Future functionality configuration.

  • variables – Runway variables.

property child_modules: List[runway.core.components._module.Module]

Return child modules.

property environment_matches_defined: Optional[bool]

Environment matches one of the defined environments.

Will return None if there is nothing defined for the current environment.

property environments: RunwayEnvironmentsType

Environments defined for the deployment and module.

property fqn

Fully qualified name.

property opts_from_file: Dict[str, Any]

Load module options from local file.

property path: runway.core.components._module_path.ModulePath

Return resolve module path.

property payload: Dict[str, Any]

Return payload to be passed to module class handler class.

property should_skip: bool

Whether the module should be skipped by Runway.

property type: runway.core.components._module_type.RunwayModuleType

Determine Runway module type.

property use_async: bool

Whether to use asynchronous method.

deploy() None[source]

Deploy the module.

High level method for running a module.

destroy() None[source]

Destroy the module.

High level method for running a module.

init() None[source]

Initialize/bootstrap module.

High level method for running a deployment.

plan() None[source]

Plan for the next deploy of the module.

High level method for running a module.

run(action: RunwayActionTypeDef) None[source]

Run a single module.

Low level API access to run a module object.

Parameters

action – Name of action to run.

__new__(**kwargs)
classmethod run_list(action: RunwayActionTypeDef, context: RunwayContext, modules: List[RunwayModuleDefinition], variables: RunwayVariablesDefinition, deployment: RunwayDeploymentDefinition = None, future: Optional[RunwayFutureDefinitionModel] = None) None[source]

Run a list of modules.

Parameters
  • action – Name of action to run.

  • context – Runway context.

  • modules – List of modules to run.

  • variables – Variable definition for resolving lookups in the module.

  • deployment – Deployment the modules are a part of.

  • future – Future functionality configuration.

__getitem__(key: str) Any[source]

Make the object subscriptable.

Parameters

key – Attribute to get.

class runway.core.components.ModulePath[source]

Bases: object

Handler for the path field of a Runway module.

__init__(definition: Optional[Union[pathlib.Path, str]] = None, *, cache_dir: pathlib.Path, deploy_environment: Optional[runway.core.components._deploy_environment.DeployEnvironment] = None) None[source]

Instantiate class.

Parameters
  • definition – Path definition.

  • cache_dir – Directory to use for caching if needed.

  • deploy_environment – Current deploy environment object.

property arguments: Dict[str, str]

Remote source arguments.

property location: str

Location of the module.

property metadata: runway.core.components._module_path.ModulePathMetadataTypeDef

Information that describes the module path.

property module_root: pathlib.Path

Root directory of the module.

property source: str

Source of the module.

property uri: str

Remote source URI.

classmethod parse_obj(obj: Optional[Union[pathlib.Path, runway.config.components.runway._module_def.RunwayModuleDefinition, runway.config.models.runway.RunwayModuleDefinitionModel, str]], *, cache_dir: pathlib.Path, deploy_environment: Optional[runway.core.components._deploy_environment.DeployEnvironment] = None) runway.core.components._module_path.ModulePath[source]

Parse object.

Parameters
  • obj – Object to parse.

  • cache_dir – Directory to use for caching if needed.

  • deploy_environment – Current deploy environment object.

Raises

TypeError – Unsupported type provided.

__new__(**kwargs)
class runway.core.components.RunwayModuleType[source]

Bases: object

Runway configuration type settings object.

The type property of a Runway configuration can be used to explicitly specify what module type you are intending to deploy.

Runway determines the type of module you are trying to deploy in 3 different ways. First, it will check for the type property as described here, next it will look for a suffix as described in Module Definition, and finally it will attempt to autodetect your module type by scanning the files of the project. If none of those settings produces a valid result an error will occur. The following are valid explicit types:

Type

IaC Tool/Framework

cdk

AWS CDK

cloudformation

CloudFormation

serverless

Serverless Framework

terraform

Terraform

kubernetes

Kubernetes

static

Static Site

Even when specifying a module type the module structure needs to be conducive with that type of project. If the files contained within don’t match the type then an error will occur.

__init__(path: Path, class_path: Optional[str] = None, type_str: Optional[RunwayModuleTypeTypeDef] = None) None[source]

Instantiate class.

Keyword Arguments
  • path – The required path to the module

  • class_path – A supplied class_path to override the autodetected one.

  • type_str – An explicit type to assign to the RunwayModuleType

__new__(**kwargs)