Closed NamsyJay closed 8 months ago
Thanks for opening this issue, can you paste the template you are using here in code blocks?
Hi @NamsyJay, it seems the runtime might be set as Runtime: python 3.9
in the template file. Can you check if setting it to Runtime: python3.9
works?
Hello,
I am facing the similar issue with below error log,
Can you please suggest the solution?
weather-data-capture sam local invoke
Invoking uk.gov.dwp.coldweatherpay.weatherdatacapture.lambda.DailyLambdaHandler::handleRequest (java18)
Decompressing /Users/vamsi.krishna/work/weather-data-capture/target/weather-data-capture-1.0.0.jar
Error: Unsupported Lambda runtime java18 Traceback: File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 783, in invoke return __callback(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/cli/cli_config_file.py", line 347, in wrapper return func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func return ctx.invoke(f, obj, *args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/opt/python-click/lib/python3.12/site-packages/click/core.py", line 783, in invoke return __callback(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 185, in wrapped raise exception # pylint: disable=raising-bad-type ^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 150, in wrapped return_value = func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/lib/utils/version_checker.py", line 43, in wrapped actual_result = func(*args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/cli/main.py", line 95, in wrapper return func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/commands/local/invoke/cli.py", line 104, in cli do_cli( File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/commands/local/invoke/cli.py", line 205, in do_cli context.local_lambda_runner.invoke( File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/commands/local/lib/local_lambda.py", line 147, in invoke self.local_runtime.invoke( File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 325, in wrapped_func return_value = func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/local/lambdafn/runtime.py", line 199, in invoke container = self.create( ^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/local/lambdafn/runtime.py", line 91, in create container = LambdaContainer( ^^^^^^^^^^^^^^^^ File "/Users/vamsi.krishna/.homebrew/Cellar/aws-sam-cli/1.109.0/libexec/lib/python3.12/site-packages/samcli/local/docker/lambda_container.py", line 98, in init raise ValueError("Unsupported Lambda runtime {}".format(runtime))
An unexpected error was encountered while executing "sam local invoke". Search for an existing issue: https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20local%20invoke%20-%20ValueError Or create a bug report: https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20local%20invoke%20-%20ValueError ➜
Template.yaml file content: AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources:
AppFunction: Type: AWS::Serverless::Function Properties: Runtime: java18 Handler: uk.gov.dwp.coldweatherpay.weatherdatacapture.lambda.DailyLambdaHandler::handleRequest Timeout: 60 MemorySize: 512 CodeUri: ./target/weather-data-capture-1.0.0.jar
Hi @vamsikrishna507, the java18
runtime that is specified in the template is not a valid runtime. For a list of valid runtimes, please reference https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html.
You can try changing the runtime to one of:
java8.al2
java11
java17
java21
Thank you Lucashuy for the details. I have used java17 and the issue fixed but led to another exception.
It seems that valid certificate is not available when i invoke sam local invoke althrough java17 has it's certificate in lib folder.
Can you please suggest the way to get rid of the exception and proceed?
I/O error on GET request for "https://api-metoffice.apiconnect.ibmcloud.com/v0/forecasts/point/hourly": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target: org.springframework.web.client.ResourceAccessException org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://api-metoffice.apiconnect.ibmcloud.com/v0/forecasts/point/hourly": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at org.springframework.web.client.RestTemplate.createResourceAccessException(RestTemplate.java:905) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:885) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:781) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:663) at uk.gov.dwp.coldweatherpay.weatherdatacapture.lambda.DailyLambdaHandler.QueryTemperature(DailyLambdaHandler.java:58)
Thanks for creating a new issue for the connection issue (ref: #6706). The team will continue to engage there. The original UX issue here is fixed and will be released in a future SAM CLI update.
Patch is released in v1.110.0. Closing
Hi @lucashuy I started getting the same issue while i my sam --version SAM CLI, version 1.123.0
Error: Connect timeout on endpoint URL: "https://sts.amazonaws.com/"
Traceback:
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/cli/cli_config_file.py", line 347, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 185, in wrapped
raise exception # pylint: disable=raising-bad-type
^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/lib/telemetry/metric.py", line 150, in wrapped
return_value = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/lib/utils/version_checker.py", line 43, in wrapped
actual_result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/cli/main.py", line 95, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/commands/local/invoke/cli.py", line 108, in cli
do_cli(
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/commands/local/invoke/cli.py", line 185, in do_cli
with InvokeContext(
^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 184, in __init__
self._add_account_id_to_global()
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 363, in _add_account_id_to_global
account_id = sts.get_caller_identity().get("Account")
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/client.py", line 569, in _api_call
return self._make_api_call(operation_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/client.py", line 1005, in _make_api_call
http, parsed_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/client.py", line 1029, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/endpoint.py", line 119, in make_request
return self._send_request(request_dict, operation_model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/endpoint.py", line 200, in _send_request
while self._needs_retry(
^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/endpoint.py", line 352, in _needs_retry
responses = self._event_emitter.emit(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/hooks.py", line 412, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/hooks.py", line 256, in emit
return self._emit(event_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/hooks.py", line 239, in _emit
response = handler(**kwargs)
^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/retryhandler.py", line 207, in __call__
if self._checker(**checker_kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/retryhandler.py", line 284, in __call__
should_retry = self._should_retry(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/retryhandler.py", line 320, in _should_retry
return self._checker(attempt_number, response, caught_exception)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/retryhandler.py", line 363, in __call__
checker_response = checker(
^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/retryhandler.py", line 247, in __call__
return self._check_caught_exception(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/retryhandler.py", line 416, in _check_caught_exception
raise caught_exception
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/endpoint.py", line 279, in _do_get_response
http_response = self._send(request)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/endpoint.py", line 375, in _send
return self.http_session.send(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.123.0/libexec/lib/python3.12/site-packages/botocore/httpsession.py", line 499, in send
raise ConnectTimeoutError(endpoint_url=request.url, error=e)
An unexpected error was encountered while executing "sam local invoke".
Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20local%20invoke%20-%20ConnectTimeoutError
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20local%20invoke%20-%20ConnectTimeoutError
My template is
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Sample AWS SAM Template
Globals:
Function:
Timeout: 30
MemorySize: 256
Runtime: python3.9
Architectures:
- x86_64
Resources:
SampleFunction1:
Type: AWS::Serverless::Function
Properties:
CodeUri: path_to_code/
Handler: app.sample_function1_handler
Environment:
Variables:
DEFAULT_FROM_EMAIL: your_email@example.com
AWS_REGION: ap-southeast-1
SampleFunction2:
Type: AWS::Serverless::Function
Properties:
CodeUri: path_to_code/
Handler: app.sample_function2_handler
Environment:
Variables:
DYNAMODB_TABLE_REVOKED: !Sub "${DYNAMODB_TABLE_REVOKED}"
AWS_REGION: !Sub "${AWS_REGION}"
SampleFunction3:
Type: AWS::Serverless::Function
Properties:
CodeUri: path_to_code/
Handler: app.sample_function3_handler
Environment:
Variables:
DYNAMODB_TABLE_REFRESH: !Sub "${DYNAMODB_TABLE_REFRESH}"
DYNAMODB_TABLE_REVOKED: !Sub "${DYNAMODB_TABLE_REVOKED}"
AWS_REGION: !Sub "${AWS_REGION}"
SampleFunction4:
Type: AWS::Serverless::Function
Properties:
CodeUri: path_to_code/
Handler: app.sample_function4_handler
Environment:
Variables:
DYNAMODB_TABLE_USERS: !Sub "${DYNAMODB_TABLE_USERS}"
DYNAMODB_TABLE_TENANTS: !Sub "${DYNAMODB_TABLE_TENANTS}"
AWS_REGION: !Sub "${AWS_REGION}"
SampleFunction5:
Type: AWS::Serverless::Function
Properties:
CodeUri: path_to_code/
Handler: app.sample_function5_handler
Environment:
Variables:
DYNAMODB_TABLE_SESSIONS: !Sub "${DYNAMODB_TABLE_SESSIONS}"
LAMBDA_FUNCTION_GENERATE_TOKEN: !Sub "${LAMBDA_FUNCTION_GENERATE_TOKEN}"
AWS_REGION: !Sub "${AWS_REGION}"
SampleFunction6:
Type: AWS::Serverless::Function
Properties:
CodeUri: path_to_code/
Handler: app.sample_function6_handler
Environment:
Variables:
DYNAMODB_TABLE_REFRESH: !Sub "${DYNAMODB_TABLE_REFRESH}"
AWS_REGION: !Sub "${AWS_REGION}"
Hi @Khnaz35, this does not appear to be the same issue. It looks like something failed to call the AWS endpoint to assume roles, have you tried running the command again in a different environment? There may have been a momentary outage somewhere between your connection and AWS, or a network configuration issue on your machine.
Additionally, you can try installing SAM CLI from our official artifacts: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html
If you are still facing issues, please create a new issue on our Github.
Description: An unexpected error was encountered while executing "sam local invoke".
Steps to reproduce:
Observed result: Error Message:- Invoking lambda_function.lambda_handler (python 3.9)
Error: Unsupported Lambda runtime python 3.9 Traceback: File "click/core.py", line 1078, in main File "click/core.py", line 1688, in invoke File "click/core.py", line 1688, in invoke File "click/core.py", line 1434, in invoke File "click/core.py", line 783, in invoke File "samcli/cli/cli_config_file.py", line 347, in wrapper File "click/decorators.py", line 92, in new_func File "click/core.py", line 783, in invoke File "samcli/lib/telemetry/metric.py", line 184, in wrapped File "samcli/lib/telemetry/metric.py", line 149, in wrapped File "samcli/lib/utils/version_checker.py", line 42, in wrapped File "samcli/cli/main.py", line 95, in wrapper File "samcli/commands/local/invoke/cli.py", line 103, in cli File "samcli/commands/local/invoke/cli.py", line 201, in do_cli File "samcli/commands/local/lib/local_lambda.py", line 144, in invoke File "samcli/lib/telemetry/metric.py", line 324, in wrapped_func File "samcli/local/lambdafn/runtime.py", line 192, in invoke File "samcli/local/lambdafn/runtime.py", line 88, in create File "samcli/local/docker/lambda_container.py", line 94, in init
Expected result:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc) SAM CLI, version 1.107.0 Python 3.9 WSL Ubuntu VS Code