runway.module.serverless module

Serverless module.

runway.module.serverless.gen_sls_config_files(stage, region)[source]

Generate possible SLS config files names.

runway.module.serverless.run_sls_print(sls_opts, env_vars, path)[source]

Run sls print command.

runway.module.serverless.get_src_hash(sls_config, path)[source]

Get hash(es) of serverless source.

runway.module.serverless.deploy_package(sls_opts, bucketname, context, path, logger=<RunwayLogger runway.module.serverless (WARNING)>)[source]

Run sls package command.

Parameters
  • sls_opts (List[str]) – List of options for Serverless CLI.

  • bucketname (str) – S3 Bucket name.

  • context (Context) – Runway context object.

  • path (str) – Module path.

  • logger (Optional[logging.Logger]) – A more granular logger for log messages.

class runway.module.serverless.Serverless(context, path, options=None)[source]

Bases: runway.module.RunwayModuleNpm

Serverless Runway Module.

Instantiate class.

Parameters
  • context (Context) – Runway context object.

  • path (str) – Path to the module.

  • options (Dict[str, Dict[str, Any]]) – Everything in the module definition merged with applicable values from the deployment definition.

property cli_args

Generate CLI args from self used in all Serverless commands.

Returns

List[str]

env_file

Decorator for creating cached properties.

A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property. Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76

property skip

Determine if the module should be skipped.

Returns

To skip, or not to skip, that is the question.

Return type

bool

extend_serverless_yml(func)[source]

Extend the Serverless config file with additional YAML from options.

Parameters

func (Callable) – Callable to use after handling the Serverless config file.

gen_cmd(command, args_list=None)[source]

Generate and log a Serverless command.

This does not execute the command, only prepares it for use.

Parameters
  • command (str) – The Serverless command to be executed.

  • args_list (Optiona[List[str]]) – Additional arguments to include in the generated command.

Returns

The full command to be passed into a subprocess.

Return type

List[str]

sls_deploy(skip_install=False)[source]

Execute sls deploy command.

Parameters

skip_install (bool) – Skip npm install before running the Serverless command. (default: False)

sls_print(item_path=None, skip_install=False)[source]

Execute sls print command.

Keyword Arguments
  • item_path (Optional[str]) – Period-separated path to print a sub-value (eg: “provider.name”).

  • skip_install (bool) – Skip npm install before running the Serverless command. (default: False)

Returns

Resolved Serverless config file.

Return type

Dict[str, Any]

Raises

SystemExit – If a runway-tmp.serverless.yml file already exists.

sls_remove(skip_install=False)[source]

Execute sls remove command.

Parameters

skip_install (bool) – Skip npm install before running the Serverless command. (default: False)

plan()[source]

Entrypoint for Runway’s plan action.

deploy()[source]

Entrypoint for Runway’s deploy action.

destroy()[source]

Entrypoint for Runway’s destroy action.

class runway.module.serverless.ServerlessOptions(args, extend_serverless_yml, promotezip, skip_npm_ci=False)[source]

Bases: runway.module.ModuleOptions

Module options for Serverless.

Instantiate class.

Keyword Arguments
  • args (List[str]) – Arguments to append to Serverless CLI commands. These will always be placed after the default arguments provided by Runway.

  • extend_serverless_yml (Dict[str, Any]) – If provided, a temporary Serverless config will be created will be created from what exists in the module directory then the value of this option will be merged into it. The temporary file will be deleted at the end of execution.

  • promotezip (Dict[str, str]) – If provided, promote Serverless generated zip files between environments from a build AWS account.

  • skip_npm_ci (bool) – Skip the npm ci Runway executes at the begining of each Serverless module run.

property args

Args to pass to the CLI.

Returns

List of arguments.

Return type

List[str]

update_args(key, value)[source]

Update a known CLI argument.

Parameters
  • key (str) – Dict key to be updated.

  • value (str) – New value

Raises

KeyError – The key provided for update is now a known arg.

classmethod parse(**kwargs)[source]

Parse the options definition and return an options object.

Keyword Arguments
  • args (Optional[List[str]]) – Arguments to append to Serverless CLI commands. These will always be placed after the default arguments provided by Runway.

  • extend_serverless_yml (Optional[Dict[str, Any]]) – If provided, a temporary Serverless config will be created will be created from what exists in the module directory then the value of this option will be merged into it. The temporary file will be deleted at the end of execution.

  • promotezip (Optional[Dict[str, str]]) – If provided, promote Serverless generated zip files between environments from a build AWS account.

  • skip_npm_ci (bool) – Skip the npm ci Runway executes at the begining of each Serverless module run.

Returns

ServerlessOptions

Raises

ValueError – promotezip was provided but missing bucketname.