runway.core.components package

Core Runway components.

class runway.core.components.DeployEnvironment(*, environ: Optional[Dict[str, str]] = None, explicit_name: Optional[str] = None, ignore_git_branch: bool = False, root_dir: Optional[Path] = None)[source]

Bases: object

Runway deploy environment.

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

Get AWS credentials from environment variables.

property aws_profile

Get AWS profile from environment variables.

property aws_region

Get AWS region from environment variables.

property branch_name

Git branch name.

property ci

Return CI status.

Returns

bool

property debug

Get debug setting from the environment.

property ignore_git_branch

Whether to ignore git branch when determining name.

property max_concurrent_cfngin_stacks

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

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

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

Deploy environment name.

property verbose

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(context: RunwayContext, definition: RunwayDeploymentDefinition, future: Optional[RunwayFutureDefinitionModel] = None, variables: Optional[RunwayVariablesDefinition] = None)[source]

Bases: object

Runway deployment.

Instantiate class.

Parameters
  • context – Runway context object.

  • definition – A single deployment definition.

  • future – Future functionality configuration.

  • variables – Runway variables.

property assume_role_config

Parse the definition to get assume role arguments.

property env_vars_config

Parse the definition to get the correct env_vars configuration.

property regions

List of regions this deployment is associated with.

property use_async

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)typing.Any[source]

Make the object subscriptable.

Parameters

name – Attribute to get.

class runway.core.components.Module(context: RunwayContext, definition: RunwayModuleDefinition, deployment: RunwayDeploymentDefinition = None, future: RunwayFutureDefinitionModel = None, variables: RunwayVariablesDefinition = None)[source]

Bases: object

Runway module.

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

Return child modules.

property environment_matches_defined

Environment matches one of the defined environments.

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

property environments

Environments defined for the deployment and module.

property fqn

Fully qualified name.

property opts_from_file

Load module options from local file.

property path

Return resolve module path.

property payload

Return payload to be passed to module class handler class.

property should_skip

Whether the module should be skipped by Runway.

property type

Determine Runway module type.

property use_async

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.

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)typing.Any[source]

Make the object subscriptable.

Parameters

key – Attribute to get.

class runway.core.components.ModulePath(definition: Optional[Union[Path, str]] = None, *, cache_dir: Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/onica-runway/checkouts/latest/docs/source/.runway/cache'), deploy_environment: Optional[DeployEnvironment] = None)[source]

Bases: object

Handler for the path field of a Runway module.

Instantiate class.

Parameters
  • definition – Path definition.

  • cache_dir – Directory to use for caching if needed.

  • deploy_environment – Current deploy environment object.

property arguments

Remote source arguments.

property location

Location of the module.

property metadata

Information that describes the module path.

property module_root

Root directory of the module.

property source

Source of the module.

property uri

Remote source URI.

classmethod parse_obj(obj: Optional[Union[Path, RunwayModuleDefinition, RunwayModuleDefinitionModel, str]], *, deploy_environment: Optional[DeployEnvironment] = None)ModulePath[source]

Parse object.

Parameters
  • obj – Object to parse.

  • deploy_environment – Current deploy environment object.

Raises

TypeError – Unsupported type provided.

class runway.core.components.RunwayModuleType(path: Path, class_path: Optional[str] = None, type_str: Optional[RunwayModuleTypeTypeDef] = None)[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.

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