runway.module.serverless module¶
Serverless module.
- class runway.module.serverless.Serverless[source]¶
Bases:
RunwayModuleNpm
[ServerlessOptions
]Serverless Runway Module.
- __init__(context: RunwayContext, *, explicitly_enabled: bool | None = False, logger: RunwayLogger = <RunwayLogger runway.module.serverless (WARNING)>, module_root: Path, name: str | None = None, options: dict[str, Any] | ModuleOptions | None = None, parameters: dict[str, Any] | None = 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
ormodule_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.
- extend_serverless_yml(func: Callable[[...], None]) None [source]¶
Extend the Serverless config file with additional YAML from options.
- Parameters:
func – Callable to use after handling the Serverless config file.
- gen_cmd(command: str, args_list: list[str] | None = None) list[str] [source]¶
Generate and log a Serverless command.
This does not execute the command, only prepares it for use.
- Parameters:
command – The Serverless command to be executed.
args_list – Additional arguments to include in the generated command.
- Returns:
The full command to be passed into a subprocess.
- sls_deploy(*, package: AnyPath | None = None, skip_install: bool = False) None [source]¶
Execute
sls deploy
command.- Parameters:
package – Path to Serverless package to deploy.
skip_install – Skip
npm ci|install
before running the Serverless command.
- sls_package(*, output_path: AnyPathConstrained | None = None, skip_install: bool = False) AnyPathConstrained | None [source]¶
Execute
sls package
command.- Parameters:
output_path – Path where the package should be output.
skip_install – Skip
npm ci|install
before running the Serverless command.
- sls_print(*, item_path: str | None = None, skip_install: bool = False) dict[str, Any] [source]¶
Execute
sls print
command.- Keyword Arguments:
item_path – Period-separated path to print a sub-value (eg: “provider.name”).
skip_install – Skip
npm ci|install
before running the Serverless command.
- Returns:
Resolved Serverless config file.
- Raises:
SystemExit – If a runway-tmp.serverless.yml file already exists.
- class runway.module.serverless.ServerlessArtifact[source]¶
Bases:
object
Object for interacting with a Serverless artifact directory.
- __init__(context: RunwayContext, config: dict[str, Any], *, logger: PrefixAdaptor | RunwayLogger = <RunwayLogger runway.module.serverless (WARNING)>, package_path: AnyPath, path: AnyPath) None [source]¶
Instantiate class.
- Parameters:
context – Runway context object.
config – Rendered Serverless config file.
logger – Logger this object will log to. If not provided, the logger in the local module will be used.
package_path – Local path to the artifact directory.
path – Root directory of the Serverless project.
- class runway.module.serverless.ServerlessOptions[source]¶
Bases:
ModuleOptions
Module options for Serverless Framework.
- data¶
Options parsed into a data model.
- extend_serverless_yml¶
If provided, the value of this option will be recursively merged into the module’s Serverless config file.
- promotezip¶
If provided, promote Serverless Framework generated zip files between environments from a build AWS account.
- skip_npm_ci¶
Skip running
npm ci
in the module directory prior to processing the module.
- __init__(data: RunwayServerlessModuleOptionsDataModel) None [source]¶
Instantiate class.
- Parameters:
data – Options parsed into a data model.
- classmethod parse_obj(obj: object) ServerlessOptions [source]¶
Parse options definition and return an options object.
- Parameters:
obj – Object to parse.