|
16 | 16 | skip_prepare_infra_option, |
17 | 17 | terraform_plan_file_option, |
18 | 18 | ) |
| 19 | +from samcli.commands.init.init_flow_helpers import get_sorted_runtimes |
19 | 20 | from samcli.commands.local.cli_common.options import invoke_common_options, local_common_options |
20 | 21 | from samcli.commands.local.invoke.core.command import InvokeCommand |
21 | 22 | from samcli.commands.local.lib.exceptions import InvalidIntermediateImageError |
22 | 23 | from samcli.lib.telemetry.metric import track_command |
23 | 24 | from samcli.lib.utils.version_checker import check_newer_version |
| 25 | +from samcli.local.common.runtime_template import INIT_RUNTIMES |
24 | 26 | from samcli.local.docker.exceptions import ( |
25 | 27 | ContainerNotStartableException, |
26 | 28 | DockerContainerCreationFailedException, |
|
65 | 67 | "is not specified, no event is assumed. Pass in the value '-' to input JSON via stdin", |
66 | 68 | ) |
67 | 69 | @click.option("--no-event", is_flag=True, default=True, help="DEPRECATED: By default no event is assumed.", hidden=True) |
| 70 | +@click.option( |
| 71 | + "-r", |
| 72 | + "--runtime", |
| 73 | + type=click.Choice(get_sorted_runtimes(INIT_RUNTIMES)), |
| 74 | + help="Lambda runtime used to invoke the function." |
| 75 | + + click.style(f"\n\nRuntimes: {', '.join(get_sorted_runtimes(INIT_RUNTIMES))}", bold=True), |
| 76 | +) |
68 | 77 | @mount_symlinks_option |
69 | 78 | @invoke_common_options |
70 | 79 | @local_common_options |
@@ -105,6 +114,7 @@ def cli( |
105 | 114 | hook_name, |
106 | 115 | skip_prepare_infra, |
107 | 116 | terraform_plan_file, |
| 117 | + runtime, |
108 | 118 | mount_symlinks, |
109 | 119 | no_memory_limit, |
110 | 120 | ): |
@@ -137,6 +147,7 @@ def cli( |
137 | 147 | add_host, |
138 | 148 | invoke_image, |
139 | 149 | hook_name, |
| 150 | + runtime, |
140 | 151 | mount_symlinks, |
141 | 152 | no_memory_limit, |
142 | 153 | ) # pragma: no cover |
@@ -166,6 +177,7 @@ def do_cli( # pylint: disable=R0914 |
166 | 177 | add_host, |
167 | 178 | invoke_image, |
168 | 179 | hook_name, |
| 180 | + runtime, |
169 | 181 | mount_symlinks, |
170 | 182 | no_mem_limit, |
171 | 183 | ): |
@@ -221,7 +233,11 @@ def do_cli( # pylint: disable=R0914 |
221 | 233 | ) as context: |
222 | 234 | # Invoke the function |
223 | 235 | context.local_lambda_runner.invoke( |
224 | | - context.function_identifier, event=event_data, stdout=context.stdout, stderr=context.stderr |
| 236 | + context.function_identifier, |
| 237 | + event=event_data, |
| 238 | + stdout=context.stdout, |
| 239 | + stderr=context.stderr, |
| 240 | + override_runtime=runtime, |
225 | 241 | ) |
226 | 242 |
|
227 | 243 | except FunctionNotFound as ex: |
|
0 commit comments