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 Nov 9, 2023
2 parents cde5759 + df79afe commit 3102565
Show file tree
Hide file tree
Showing 77 changed files with 1,143 additions and 1,066 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ concurrency:
jobs:
run-workflow:
name: PR Workflow
if: github.repository_owner == 'aws'
# If any dependent jobs fails, this WF skips which won't block merging PRs
# calling always() is required for this WF to run all the time
if: github.repository_owner == 'aws' && always()
runs-on: ubuntu-latest
needs:
- make-pr
Expand Down
14 changes: 7 additions & 7 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ click~=8.1
Flask<3.1
boto3>=1.26.109,<2
jmespath~=1.0.1
ruamel_yaml~=0.18.1
ruamel_yaml~=0.18.5
PyYAML~=6.0,>=6.0.1
cookiecutter~=2.3.1
cookiecutter~=2.4.0
aws-sam-translator==1.79.0
#docker minor version updates can include breaking changes. Auto update micro version only.
docker~=6.1.0
dateparser~=1.1
requests~=2.31.0
aws_lambda_builders==1.40.0
tomlkit==0.12.1
tomlkit==0.12.2
watchdog==3.0.0
rich~=13.6.0
pyopenssl~=23.2.0
pyopenssl~=23.3.0
# Pin to <4.18 to until SAM-T no longer uses RefResolver
jsonschema<4.20

Expand All @@ -25,10 +25,10 @@ typing_extensions>=4.4.0,<5
# NOTE: regex is not a direct dependency of SAM CLI, exclude version 2021.10.8 due to not working on M1 Mac - https://github.com/mrabarnett/mrab-regex/issues/399
regex!=2021.10.8
# NOTE: tzlocal is not a direct dependency of SAM CLI, but pin to 3.0 as 4.0 break appveyor jobs
tzlocal==5.1
tzlocal==5.2

#Adding cfn-lint dependency for SAM validate
cfn-lint~=0.83.0
cfn-lint~=0.83.1

# Type checking boto3 objects
boto3-stubs[apigateway,cloudformation,ecr,iam,lambda,s3,schemas,secretsmanager,signer,stepfunctions,sts,xray,sqs,kinesis]==1.28.69
boto3-stubs[apigateway,cloudformation,ecr,iam,lambda,s3,schemas,secretsmanager,signer,stepfunctions,sts,xray,sqs,kinesis]==1.28.80
8 changes: 4 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pytest-cov==4.1.0
# type checking and related stubs
# mypy adds new rules in new minor versions, which could cause our PR check to fail
# here we fix its version and upgrade it manually in the future
mypy==1.5.1
mypy==1.6.1
types-pywin32==306.0.0.4
types-PyYAML==6.0.12.11
types-chevron==0.14.2.5
Expand All @@ -23,7 +23,7 @@ types-requests==2.31.0.2
types-urllib3==1.26.25.14

# Test requirements
pytest~=7.4.2
pytest~=7.4.3
parameterized==0.9.0
pytest-xdist==3.3.1
pytest-forked==1.6.0
Expand All @@ -32,8 +32,8 @@ pytest-rerunfailures==12.0
# NOTE (hawflau): DO NOT upgrade pytest-metadata and pytest-json-report unless pytest-json-report addresses https://github.com/numirias/pytest-json-report/issues/89
pytest-metadata==2.0.4
pytest-json-report==1.5.0
filelock==3.12.4
filelock==3.13.1

# formatter
black==23.10.1
black==23.11.0
psutil==5.9.6
2 changes: 1 addition & 1 deletion requirements/pre-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff==0.1.0
ruff==0.1.4
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==68.2.2
pyinstaller==6.0.0
pyinstaller==6.1.0
609 changes: 311 additions & 298 deletions requirements/reproducible-linux.txt

Large diffs are not rendered by default.

603 changes: 308 additions & 295 deletions requirements/reproducible-mac.txt

Large diffs are not rendered by default.

603 changes: 308 additions & 295 deletions requirements/reproducible-win.txt

Large diffs are not rendered by default.

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.100.0"
__version__ = "1.101.0"
1 change: 1 addition & 0 deletions samcli/cli/hidden_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ def walk_modules(module: ModuleType, visited: set) -> None:
"dateparser",
"jsonschema",
"cfnlint",
"networkx.generators",
]
4 changes: 2 additions & 2 deletions samcli/commands/remote/remote_invoke_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class DefaultRemoteInvokeResponseConsumer(RemoteInvokeConsumer[RemoteInvokeRespo
_stream_writer: StreamWriter

def consume(self, remote_invoke_response: RemoteInvokeResponse) -> None:
self._stream_writer.write_bytes(cast(str, remote_invoke_response.response).encode())
self._stream_writer.write_str(cast(str, remote_invoke_response.response))


@dataclass
Expand All @@ -290,4 +290,4 @@ class DefaultRemoteInvokeLogConsumer(RemoteInvokeConsumer[RemoteInvokeLogOutput]
_stream_writer: StreamWriter

def consume(self, remote_invoke_response: RemoteInvokeLogOutput) -> None:
self._stream_writer.write_bytes(remote_invoke_response.log_output.encode())
self._stream_writer.write_str(remote_invoke_response.log_output)
9 changes: 9 additions & 0 deletions samcli/lib/build/build_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
HANDLER_FIELD = "handler"
SHARED_CODEURI_SUFFIX = "Shared"

# Compiled runtimes that we need to compare handlers for
COMPILED_RUNTIMES = ["go1.x"]


def _function_build_definition_to_toml_table(
function_build_definition: "FunctionBuildDefinition",
Expand Down Expand Up @@ -677,6 +680,12 @@ def __eq__(self, other: Any) -> bool:
if self.handler != other.handler:
return False

if self.runtime in COMPILED_RUNTIMES:
# For compiled languages, we need to check if handlers within the same CodeUri are the same
# if they are different, it should create a separate build definition
if self.handler != other.handler:
return False

return (
self.runtime == other.runtime
and self.codeuri == other.codeuri
Expand Down
1 change: 1 addition & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def get_workflow_config(
),
"provided": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
"provided.al2": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
"provided.al2023": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
}

selectors_by_builder = {
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/docs/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import logging
from pathlib import Path
from typing import Any, Dict
from typing import Dict

from samcli.lib.docs.browser_configuration import BrowserConfiguration

Expand Down Expand Up @@ -58,7 +58,7 @@ def get_docs_link_for_command(self) -> str:
return Documentation.load().get(self.command, LANDING_PAGE)

@staticmethod
def load() -> Dict[str, Any]:
def load() -> Dict[str, str]:
"""
Opens the configuration file and returns the contents
Expand Down
10 changes: 5 additions & 5 deletions samcli/lib/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def __init__(
location: str,
parameters: Optional[Dict],
template_dict: Dict,
metadata: Optional[Dict] = None,
metadata: Optional[Dict[str, str]] = None,
):
self.parent_stack_path = parent_stack_path
self.name = name
Expand All @@ -596,8 +596,8 @@ def __init__(

@property
def stack_id(self) -> str:
_metadata = self.metadata if self.metadata else {}
return _metadata.get(SAM_RESOURCE_ID_KEY, self.name) if self.metadata else self.name
_metadata: Dict[str, str] = self.metadata or {}
return _metadata.get(SAM_RESOURCE_ID_KEY, self.name)

@property
def stack_path(self) -> str:
Expand Down Expand Up @@ -626,7 +626,7 @@ def resources(self) -> Dict:
if self._resources is not None:
return self._resources
processed_template_dict: Dict[str, Dict] = SamBaseProvider.get_template(self.template_dict, self.parameters)
self._resources = cast(Dict, processed_template_dict.get("Resources", {}))
self._resources = processed_template_dict.get("Resources", {})
return self._resources

@property
Expand Down Expand Up @@ -937,7 +937,7 @@ def get_unique_resource_ids(
return output_resource_ids


def get_skip_build(metadata: Optional[Dict]) -> bool:
def get_skip_build(metadata: Optional[Dict[str, bool]]) -> bool:
"""
Returns the value of SkipBuild property from Metadata, False if it is not defined
"""
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/providers/sam_base_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _extract_lambda_function_imageuri(resource_properties: Dict, code_property_k
return cast(Optional[str], resource_properties.get(code_property_key, dict()).get("ImageUri", None))

@staticmethod
def _extract_sam_function_imageuri(resource_properties: Dict, code_property_key: str) -> Optional[str]:
def _extract_sam_function_imageuri(resource_properties: Dict[str, str], code_property_key: str) -> Optional[str]:
"""
Extracts the Serverless Function ImageUri from the Resource Properties
Expand All @@ -161,7 +161,7 @@ def _extract_sam_function_imageuri(resource_properties: Dict, code_property_key:
str
Representing the local imageuri
"""
return resource_properties.get(code_property_key, None)
return resource_properties.get(code_property_key)

@staticmethod
def get_template(
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 @@ -33,6 +33,7 @@
"dotnet6": [ARM64, X86_64],
"provided": [X86_64],
"provided.al2": [ARM64, X86_64],
"provided.al2023": [ARM64, X86_64],
}


Expand Down
16 changes: 1 addition & 15 deletions samcli/lib/utils/stream_writer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This class acts like a wrapper around output streams to provide any flexibility with output we need
"""
from typing import TextIO, Union
from typing import TextIO


class StreamWriter:
Expand All @@ -23,20 +23,6 @@ def __init__(self, stream: TextIO, auto_flush: bool = False):
def stream(self) -> TextIO:
return self._stream

def write_bytes(self, output: Union[bytes, bytearray]):
"""
Writes specified text to the underlying stream
Parameters
----------
output bytes-like object
Bytes to write into buffer
"""
self._stream.buffer.write(output)

if self._auto_flush:
self._stream.flush()

def write_str(self, output: str):
"""
Writes specified text to the underlying stream
Expand Down
4 changes: 3 additions & 1 deletion samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def get_local_lambda_images_location(mapping, runtime):
"nodejs14.x",
"nodejs12.x",
# custom runtime in descending order
"provided.al2023",
"provided.al2",
"provided",
# python runtimes in descending order
Expand All @@ -130,6 +131,7 @@ def get_local_lambda_images_location(mapping, runtime):
"dotnet6": "amazon/dotnet6-base",
"go1.x": "amazon/go1.x-base",
"go (provided.al2)": "amazon/go-provided.al2-base",
"go (provided.al2023)": "amazon/go-provided.al2023-base",
"java17": "amazon/java17-base",
"java11": "amazon/java11-base",
"java8.al2": "amazon/java8.al2-base",
Expand Down Expand Up @@ -165,7 +167,7 @@ def get_local_lambda_images_location(mapping, runtime):
"go1.x": "Go1",
}

PROVIDED_RUNTIMES = ["provided.al2", "provided"]
PROVIDED_RUNTIMES = ["provided.al2023", "provided.al2", "provided"]


def is_custom_runtime(runtime):
Expand Down
10 changes: 5 additions & 5 deletions samcli/local/docker/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def wait_for_result(self, full_path, event, stdout, stderr, start_timer=None):
if isinstance(response, str):
stdout.write_str(response)
elif isinstance(response, bytes):
stdout.write_bytes(response)
stdout.write_str(response.decode("utf-8"))
stdout.flush()
stderr.write_str("\n")
stderr.flush()
Expand Down Expand Up @@ -473,16 +473,16 @@ def _handle_data_writing(output_stream: Union[StreamWriter, io.BytesIO, io.TextI
# with carriage returns from the RIE. If these are left in the string then only the last line after
# the carriage return will be printed instead of the entire stack trace. Encode the string after cleaning
# to be printed by the correct output stream
output_data = output_data.decode("utf-8").replace("\r", os.linesep).encode("utf-8")
output_str = output_data.decode("utf-8").replace("\r", os.linesep)
if isinstance(output_stream, StreamWriter):
output_stream.write_bytes(output_data)
output_stream.write_str(output_str)
output_stream.flush()

if isinstance(output_stream, io.BytesIO):
output_stream.write(output_data)
output_stream.write(output_str.encode("utf-8"))

if isinstance(output_stream, io.TextIOWrapper):
output_stream.buffer.write(output_data)
output_stream.buffer.write(output_str.encode("utf-8"))

@property
def network_id(self):
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 @@ -51,6 +51,7 @@ class Runtime(Enum):
dotnet6 = "dotnet6"
provided = "provided"
providedal2 = "provided.al2"
providedal2023 = "provided.al2023"

@classmethod
def has_value(cls, value):
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": "fa5ce2ccab1cd25c095b8de97c6cafcd075bd897"
"app_template_repo_commit": "c8e165581d9bccbe9cd74ed60e2e82abba3f7723"
}
8 changes: 5 additions & 3 deletions schema/samcli.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"properties": {
"parameters": {
"title": "Parameters for the init command",
"description": "Available parameters for the init command:\n* no_interactive:\nDisable interactive prompting for init parameters. (fail if any required values are missing)\n* architecture:\nArchitectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\n\nRuntimes: dotnet6, go1.x, java17, java11, java8.al2, java8, nodejs18.x, nodejs16.x, nodejs14.x, nodejs12.x, provided, provided.al2, python3.9, python3.8, python3.7, python3.11, python3.10, ruby3.2, ruby2.7\n* package_type:\nLambda deployment package type.\n\nPackage Types: Zip, Image\n* base_image:\nLambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/go-provided.al2-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java8-base, amazon/java8.al2-base, amazon/nodejs12.x-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.7-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby2.7-base, amazon/ruby3.2-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip\n* output_dir:\nDirectory to initialize AWS SAM application.\n* name:\nName of AWS SAM Application.\n* app_template:\nIdentifier of the managed application template to be used. Alternatively, run '$sam init' without options for an interactive workflow.\n* no_input:\nDisable Cookiecutter prompting and accept default values defined in the cookiecutter config.\n* extra_context:\nOverride custom parameters in the template's cookiecutter.json configuration e.g. {\"customParam1\": \"customValue1\", \"customParam2\":\"customValue2\"}\n* tracing:\nEnable AWS X-Ray tracing for application.\n* application_insights:\nEnable CloudWatch Application Insights monitoring for application.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* save_params:\nSave the parameters provided via the command line to the configuration file.",
"description": "Available parameters for the init command:\n* no_interactive:\nDisable interactive prompting for init parameters. (fail if any required values are missing)\n* architecture:\nArchitectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\n\nRuntimes: dotnet6, go1.x, java17, java11, java8.al2, java8, nodejs18.x, nodejs16.x, nodejs14.x, nodejs12.x, provided, provided.al2, provided.al2023, python3.9, python3.8, python3.7, python3.11, python3.10, ruby3.2, ruby2.7\n* package_type:\nLambda deployment package type.\n\nPackage Types: Zip, Image\n* base_image:\nLambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/go-provided.al2-base, amazon/go-provided.al2023-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java8-base, amazon/java8.al2-base, amazon/nodejs12.x-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.7-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby2.7-base, amazon/ruby3.2-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip\n* output_dir:\nDirectory to initialize AWS SAM application.\n* name:\nName of AWS SAM Application.\n* app_template:\nIdentifier of the managed application template to be used. Alternatively, run '$sam init' without options for an interactive workflow.\n* no_input:\nDisable Cookiecutter prompting and accept default values defined in the cookiecutter config.\n* extra_context:\nOverride custom parameters in the template's cookiecutter.json configuration e.g. {\"customParam1\": \"customValue1\", \"customParam2\":\"customValue2\"}\n* tracing:\nEnable AWS X-Ray tracing for application.\n* application_insights:\nEnable CloudWatch Application Insights monitoring for application.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* save_params:\nSave the parameters provided via the command line to the configuration file.",
"type": "object",
"properties": {
"no_interactive": {
Expand All @@ -48,7 +48,7 @@
"runtime": {
"title": "runtime",
"type": "string",
"description": "Lambda runtime for application.\n\nRuntimes: dotnet6, go1.x, java17, java11, java8.al2, java8, nodejs18.x, nodejs16.x, nodejs14.x, nodejs12.x, provided, provided.al2, python3.9, python3.8, python3.7, python3.11, python3.10, ruby3.2, ruby2.7",
"description": "Lambda runtime for application.\n\nRuntimes: dotnet6, go1.x, java17, java11, java8.al2, java8, nodejs18.x, nodejs16.x, nodejs14.x, nodejs12.x, provided, provided.al2, provided.al2023, python3.9, python3.8, python3.7, python3.11, python3.10, ruby3.2, ruby2.7",
"enum": [
"dotnet6",
"go1.x",
Expand All @@ -62,6 +62,7 @@
"nodejs18.x",
"provided",
"provided.al2",
"provided.al2023",
"python3.10",
"python3.11",
"python3.7",
Expand All @@ -83,10 +84,11 @@
"base_image": {
"title": "base_image",
"type": "string",
"description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/go-provided.al2-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java8-base, amazon/java8.al2-base, amazon/nodejs12.x-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.7-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby2.7-base, amazon/ruby3.2-base",
"description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/go-provided.al2-base, amazon/go-provided.al2023-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java8-base, amazon/java8.al2-base, amazon/nodejs12.x-base, amazon/nodejs14.x-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.7-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby2.7-base, amazon/ruby3.2-base",
"enum": [
"amazon/dotnet6-base",
"amazon/go-provided.al2-base",
"amazon/go-provided.al2023-base",
"amazon/go1.x-base",
"amazon/java11-base",
"amazon/java17-base",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
InlineCode: |
exports.handler = async (event, context, callback) => {
return {
Expand Down
Loading

0 comments on commit 3102565

Please sign in to comment.