Skip to content

Commit

Permalink
Merge from aws/aws-sam-cli/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-sam-cli-bot authored Jul 19, 2023
2 parents 5ba20b5 + 9a4f00d commit 917ef56
Show file tree
Hide file tree
Showing 33 changed files with 460 additions and 80 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ jobs:
with:
# These are the versions of Python that correspond to the supported Lambda runtimes
python-version: |
3.11
3.10
3.9
3.8
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ docker~=6.1.0
dateparser~=1.1
requests~=2.31.0
serverlessrepo==0.1.10
aws_lambda_builders==1.34.0
aws_lambda_builders==1.35.0
tomlkit==0.11.8
watchdog==2.1.2
rich~=13.4.2
Expand Down
2 changes: 1 addition & 1 deletion requirements/pyinstaller-build.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Executable binary builder requirements
setuptools==67.7.2
pyinstaller==5.10.1
pyinstaller==5.13.0
12 changes: 6 additions & 6 deletions requirements/reproducible-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ attrs==23.1.0 \
# jschema-to-python
# jsonschema
# sarif-om
aws-lambda-builders==1.34.0 \
--hash=sha256:0790f7e9b7ee7286b96fbcf49450c5be0341bb7cb852ca7d74beae190139eb48 \
--hash=sha256:20456a942a417407b42ecf8ab7fce6a47306fd063051e7cb09d02d1be24d5cf3
aws-lambda-builders==1.35.0 \
--hash=sha256:419d766e60ac2a7303a23889b354d108a4244ce8d467dcf9dc71a62461895780 \
--hash=sha256:cf462961ec8c9d493f82b955d6b76630dc0ed356b166caddd5436719ce599586
# via aws-sam-cli (setup.py)
aws-sam-translator==1.71.0 \
--hash=sha256:17fb87c8137d8d49e7a978396b2b3b279211819dee44618415aab1e99c2cb659 \
Expand Down Expand Up @@ -302,9 +302,9 @@ junit-xml==1.9 \
--hash=sha256:de16a051990d4e25a3982b2dd9e89d671067548718866416faec14d9de56db9f \
--hash=sha256:ec5ca1a55aefdd76d28fcc0b135251d156c7106fa979686a4b48d62b761b4732
# via cfn-lint
markdown-it-py==2.2.0 \
--hash=sha256:5a35f8d1870171d9acc47b99612dc146129b631baf04970128b568f190d0cc30 \
--hash=sha256:7c9a5e412688bc771c67432cbfebcdd686c93ce6484913dccf06cb5a0bea35a1
markdown-it-py==3.0.0 \
--hash=sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1 \
--hash=sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb
# via rich
markupsafe==2.1.3 \
--hash=sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e \
Expand Down
12 changes: 6 additions & 6 deletions requirements/reproducible-mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ attrs==23.1.0 \
# jschema-to-python
# jsonschema
# sarif-om
aws-lambda-builders==1.34.0 \
--hash=sha256:0790f7e9b7ee7286b96fbcf49450c5be0341bb7cb852ca7d74beae190139eb48 \
--hash=sha256:20456a942a417407b42ecf8ab7fce6a47306fd063051e7cb09d02d1be24d5cf3
aws-lambda-builders==1.35.0 \
--hash=sha256:419d766e60ac2a7303a23889b354d108a4244ce8d467dcf9dc71a62461895780 \
--hash=sha256:cf462961ec8c9d493f82b955d6b76630dc0ed356b166caddd5436719ce599586
# via aws-sam-cli (setup.py)
aws-sam-translator==1.71.0 \
--hash=sha256:17fb87c8137d8d49e7a978396b2b3b279211819dee44618415aab1e99c2cb659 \
Expand Down Expand Up @@ -328,9 +328,9 @@ junit-xml==1.9 \
--hash=sha256:de16a051990d4e25a3982b2dd9e89d671067548718866416faec14d9de56db9f \
--hash=sha256:ec5ca1a55aefdd76d28fcc0b135251d156c7106fa979686a4b48d62b761b4732
# via cfn-lint
markdown-it-py==2.2.0 \
--hash=sha256:5a35f8d1870171d9acc47b99612dc146129b631baf04970128b568f190d0cc30 \
--hash=sha256:7c9a5e412688bc771c67432cbfebcdd686c93ce6484913dccf06cb5a0bea35a1
markdown-it-py==3.0.0 \
--hash=sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1 \
--hash=sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb
# via rich
markupsafe==2.1.3 \
--hash=sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e \
Expand Down
2 changes: 1 addition & 1 deletion samcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
SAM CLI version
"""

__version__ = "1.91.0"
__version__ = "1.92.0"
2 changes: 1 addition & 1 deletion samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
\b
Supported Runtimes
------------------
1. Python 3.7, 3.8, 3.9, 3.10 using PIP\n
1. Python 3.7, 3.8, 3.9, 3.10, 3.11 using PIP\n
2. Nodejs 18.x, 16.x, 14.x, 12.x using NPM\n
3. Ruby 2.7, 3.2 using Bundler\n
4. Java 8, Java 11, Java 17 using Gradle and Maven\n
Expand Down
2 changes: 2 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def get_layer_subfolder(build_workflow: str) -> str:
"python3.8": "python",
"python3.9": "python",
"python3.10": "python",
"python3.11": "python",
"nodejs4.3": "nodejs",
"nodejs6.10": "nodejs",
"nodejs8.10": "nodejs",
Expand Down Expand Up @@ -155,6 +156,7 @@ def get_workflow_config(
"python3.8": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.9": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.10": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.11": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"nodejs12.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs14.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs16.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
Expand Down
2 changes: 1 addition & 1 deletion samcli/lib/providers/cfn_api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def _extract_cfn_gateway_v2_stage(
api_resource_type = resources.get(api_id, {}).get("Type")
if api_resource_type != AWS_APIGATEWAY_V2_API:
raise InvalidSamTemplateException(
"The AWS::ApiGatewayV2::Stag must have a valid ApiId that points to Api resource {}".format(api_id)
"The AWS::ApiGatewayV2::Stage must have a valid ApiId that points to Api resource {}".format(api_id)
)

collector.stage_name = stage_name
Expand Down
19 changes: 12 additions & 7 deletions samcli/lib/remote_invoke/lambda_invoke_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import base64
import json
import logging
import typing
from abc import ABC, abstractmethod
from json import JSONDecodeError
from typing import cast

from botocore.eventstream import EventStream
from botocore.exceptions import ClientError, ParamValidationError
from botocore.response import StreamingBody
from mypy_boto3_lambda.client import LambdaClient

if typing.TYPE_CHECKING: # pragma: no cover
from mypy_boto3_lambda.client import LambdaClient

from samcli.lib.remote_invoke.exceptions import (
ErrorBotoApiCallException,
Expand Down Expand Up @@ -47,11 +50,13 @@ class AbstractLambdaInvokeExecutor(BotoActionExecutor, ABC):
For Payload parameter, if a file location provided, the file handle will be passed as Payload object
"""

_lambda_client: LambdaClient
_lambda_client: "LambdaClient"
_function_name: str
_remote_output_format: RemoteInvokeOutputFormat

def __init__(self, lambda_client: LambdaClient, function_name: str, remote_output_format: RemoteInvokeOutputFormat):
def __init__(
self, lambda_client: "LambdaClient", function_name: str, remote_output_format: RemoteInvokeOutputFormat
):
self._lambda_client = lambda_client
self._function_name = function_name
self._remote_output_format = remote_output_format
Expand Down Expand Up @@ -159,16 +164,16 @@ class DefaultConvertToJSON(RemoteInvokeRequestResponseMapper[RemoteInvokeExecuti
def map(self, test_input: RemoteInvokeExecutionInfo) -> RemoteInvokeExecutionInfo:
if not test_input.is_file_provided():
if not test_input.payload:
LOG.debug("Input event not found, invoking Lambda Function with an empty event")
LOG.debug("Input event not found, invoking resource with an empty event")
test_input.payload = "{}"
LOG.debug("Mapping input Payload to JSON string object")
LOG.debug("Mapping input event to JSON string object")
try:
_ = json.loads(cast(str, test_input.payload))
except JSONDecodeError:
json_value = json.dumps(test_input.payload)
LOG.info(
"Auto converting value '%s' into JSON '%s'. "
"If you don't want auto-conversion, please provide a JSON string as payload",
"If you don't want auto-conversion, please provide a JSON string as event",
test_input.payload,
json_value,
)
Expand Down Expand Up @@ -219,7 +224,7 @@ def map(self, remote_invoke_input: RemoteInvokeResponse) -> RemoteInvokeResponse
return remote_invoke_input


def _is_function_invoke_mode_response_stream(lambda_client: LambdaClient, function_name: str):
def _is_function_invoke_mode_response_stream(lambda_client: "LambdaClient", function_name: str):
"""
Returns True if given function has RESPONSE_STREAM as InvokeMode, False otherwise
"""
Expand Down
9 changes: 6 additions & 3 deletions samcli/lib/remote_invoke/stepfunctions_invoke_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"""
import logging
import time
import typing
from datetime import datetime
from typing import cast

from botocore.exceptions import ClientError, ParamValidationError
from mypy_boto3_stepfunctions import SFNClient

if typing.TYPE_CHECKING: # pragma: no cover
from mypy_boto3_stepfunctions import SFNClient

from samcli.lib.remote_invoke.exceptions import (
ErrorBotoApiCallException,
Expand Down Expand Up @@ -38,13 +41,13 @@ class StepFunctionsStartExecutionExecutor(BotoActionExecutor):
execution details.
"""

_stepfunctions_client: SFNClient
_stepfunctions_client: "SFNClient"
_state_machine_arn: str
_remote_output_format: RemoteInvokeOutputFormat
request_parameters: dict

def __init__(
self, stepfunctions_client: SFNClient, physical_id: str, remote_output_format: RemoteInvokeOutputFormat
self, stepfunctions_client: "SFNClient", physical_id: str, remote_output_format: RemoteInvokeOutputFormat
):
self._stepfunctions_client = stepfunctions_client
self._remote_output_format = remote_output_format
Expand Down
1 change: 1 addition & 0 deletions samcli/lib/utils/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"python3.8": [ARM64, X86_64],
"python3.9": [ARM64, X86_64],
"python3.10": [ARM64, X86_64],
"python3.11": [ARM64, X86_64],
"ruby2.7": [ARM64, X86_64],
"ruby3.2": [ARM64, X86_64],
"java8": [X86_64],
Expand Down
2 changes: 1 addition & 1 deletion samcli/lib/utils/preview_runtimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"""
from typing import Set

PREVIEW_RUNTIMES: Set[str] = set()
PREVIEW_RUNTIMES: Set[str] = {"python3.11"}
5 changes: 4 additions & 1 deletion samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
RUNTIME_DEP_TEMPLATE_MAPPING = {
"python": [
{
"runtimes": ["python3.10", "python3.9", "python3.8", "python3.7"],
"runtimes": ["python3.11", "python3.10", "python3.9", "python3.8", "python3.7"],
"dependency_manager": "pip",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"),
"build": True,
Expand Down Expand Up @@ -113,6 +113,7 @@ def get_local_lambda_images_location(mapping, runtime):
"provided.al2",
"provided",
# python runtimes in descending order
"python3.11",
"python3.10",
"python3.9",
"python3.8",
Expand All @@ -135,6 +136,7 @@ def get_local_lambda_images_location(mapping, runtime):
"nodejs16.x": "amazon/nodejs16.x-base",
"nodejs14.x": "amazon/nodejs14.x-base",
"nodejs12.x": "amazon/nodejs12.x-base",
"python3.11": "amazon/python3.11-base",
"python3.10": "amazon/python3.10-base",
"python3.9": "amazon/python3.9-base",
"python3.8": "amazon/python3.8-base",
Expand All @@ -156,6 +158,7 @@ def get_local_lambda_images_location(mapping, runtime):
"python3.8": "Python36",
"python3.9": "Python36",
"python3.10": "Python36",
"python3.11": "Python36",
"dotnet6": "dotnet6",
"go1.x": "Go1",
}
Expand Down
4 changes: 4 additions & 0 deletions samcli/local/docker/lambda_debug_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
entry + ["/var/lang/bin/python3.10"] + debug_args_list + ["/var/runtime/bootstrap.py"],
container_env_vars=_container_env_vars,
),
Runtime.python311.value: lambda: DebugSettings(
entry + ["/var/lang/bin/python3.11"] + debug_args_list + ["/var/runtime/bootstrap.py"],
container_env_vars=_container_env_vars,
),
}
try:
return entrypoint_mapping[runtime]()
Expand Down
1 change: 1 addition & 0 deletions samcli/local/docker/lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Runtime(Enum):
python38 = "python3.8"
python39 = "python3.9"
python310 = "python3.10"
python311 = "python3.11"
ruby27 = "ruby2.7"
ruby32 = "ruby3.2"
java8 = "java8"
Expand Down
2 changes: 1 addition & 1 deletion samcli/runtime_config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"app_template_repo_commit": "bb905c379830c3d8edbc196bda731076549028e3"
"app_template_repo_commit": "70788081366ff232a25a8b31961f59d27103e449"
}
2 changes: 2 additions & 0 deletions tests/integration/buildcmd/test_build_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def _validate_skipped_built_function(
("template.yaml", "Function", True, "python3.8", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.9", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.10", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.11", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.7", "PythonPEP600", False, "CodeUri"),
("template.yaml", "Function", True, "python3.8", "PythonPEP600", False, "CodeUri"),
],
Expand Down Expand Up @@ -479,6 +480,7 @@ def test_with_default_requirements(self):
("template.yaml", "Function", True, "python3.8", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.9", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.10", "Python", False, "CodeUri"),
("template.yaml", "Function", True, "python3.11", "Python", False, "CodeUri"),
],
)
class TestBuildCommand_PythonFunctions_WithDocker(BuildIntegPythonBase):
Expand Down
17 changes: 9 additions & 8 deletions tests/integration/remote/invoke/remote_invoke_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
run_command,
)
from tests.integration.deploy.deploy_integ_base import DeployIntegBase
from samcli.lib.remote_invoke.remote_invoke_executor_factory import RemoteInvokeExecutorFactory

from samcli.lib.utils.boto_utils import get_boto_resource_provider_with_config, get_boto_client_provider_with_config
from samcli.lib.utils.cloudformation import get_resource_summaries
Expand Down Expand Up @@ -47,17 +48,17 @@ def remote_invoke_deploy_stack(stack_name, template_path):
@classmethod
def create_resources_and_boto_clients(cls):
cls.remote_invoke_deploy_stack(cls.stack_name, cls.template_path)
stack_resource_summaries = get_resource_summaries(
boto_client_provider = get_boto_client_provider_with_config()
cls.stack_resource_summaries = get_resource_summaries(
get_boto_resource_provider_with_config(),
get_boto_client_provider_with_config(),
boto_client_provider,
cls.stack_name,
)
cls.stack_resources = {
resource_full_path: stack_resource_summary.physical_resource_id
for resource_full_path, stack_resource_summary in stack_resource_summaries.items()
}
cls.cfn_client = get_boto_client_provider_with_config()("cloudformation")
cls.lambda_client = get_boto_client_provider_with_config()("lambda")
cls.supported_resources = RemoteInvokeExecutorFactory.REMOTE_INVOKE_EXECUTOR_MAPPING.keys()
cls.cfn_client = boto_client_provider("cloudformation")
cls.lambda_client = boto_client_provider("lambda")
cls.stepfunctions_client = boto_client_provider("stepfunctions")
cls.xray_client = boto_client_provider("xray")

@staticmethod
def get_command_list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestInvokeResponseStreamingLambdas(RemoteInvokeIntegBase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.stack_name = f"{TestInvokeResponseStreamingLambdas.__name__}-{uuid.uuid4().hex}"
cls.stack_name = f"{cls.__name__}-{uuid.uuid4().hex}"
cls.create_resources_and_boto_clients()

def test_invoke_empty_event_provided(self):
Expand Down
Loading

0 comments on commit 917ef56

Please sign in to comment.