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 Apr 20, 2023
2 parents 356ed63 + a1deb7c commit 6c45ed9
Show file tree
Hide file tree
Showing 68 changed files with 1,697 additions and 440 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '11'
java-version: '17'
# Install and configure Rust
- name: Install rustup
run: |
Expand Down
15 changes: 12 additions & 3 deletions appveyor-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ install:
- sh: "gvm use go1.19"
- sh: "echo $PATH"
- sh: "ls /usr/"
- sh: "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64"
# install latest maven which is compatible with jdk17
- sh: "sudo apt-get -y remove maven"
- sh: "wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.zip -P /tmp"
- sh: "sudo unzip -d /opt/mvn /tmp/apache-maven-*.zip"
- sh: "PATH=/opt/mvn/apache-maven-3.8.8/bin:$PATH"
- sh: "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
- sh: "PATH=$JAVA_HOME/bin:$PATH"
- sh: "javac -version"
- sh: "java -version"
- sh: "mvn --version"

- sh: "source ${HOME}/venv${PYTHON_VERSION}/bin/activate"
- sh: "rvm use 2.7.2"
- sh: "docker --version"
Expand All @@ -73,9 +82,9 @@ install:

# Install latest gradle
- sh: "sudo apt-get -y remove gradle"
- sh: "wget https://services.gradle.org/distributions/gradle-5.5-bin.zip -P /tmp"
- sh: "wget https://services.gradle.org/distributions/gradle-7.3.1-bin.zip -P /tmp"
- sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip"
- sh: "PATH=/opt/gradle/gradle-5.5/bin:$PATH"
- sh: "PATH=/opt/gradle/gradle-7.3.1/bin:$PATH"

# Install AWS CLI
- sh: "virtualenv aws_cli"
Expand Down
3 changes: 3 additions & 0 deletions appveyor-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ install:
- "choco install make"
# setup Java, Maven and Gradle
- "choco install gradle -y --force"
- 'set JAVA_HOME=C:\Program Files\Java\jdk17'
- 'set PATH=%JAVA_HOME%\bin;%PATH%'
- "javac -version"
- "java -version"
- "gradle -v"
- "mvn --version"
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker~=4.2.0
dateparser~=1.1
requests==2.28.2
serverlessrepo==0.1.10
aws_lambda_builders==1.29.0
aws_lambda_builders==1.30.0
tomlkit==0.11.7
watchdog==2.1.2
pyopenssl==23.0.0
Expand Down
6 changes: 3 additions & 3 deletions requirements/reproducible-linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ attrs==22.2.0 \
# jschema-to-python
# jsonschema
# sarif-om
aws-lambda-builders==1.29.0 \
--hash=sha256:292e4a52550a27a80a46f66b3d3256840f252df343ef82c38f5d89f3073e9820 \
--hash=sha256:dca37c6beb1fc88958a02aea20bc529ccea5694d489541e91199b49fcbd0bc0a
aws-lambda-builders==1.30.0 \
--hash=sha256:861d3e6099590562fcb9f6fc5d014a26f5b5fc8aebb1d18529cd4179514f2a48 \
--hash=sha256:ab22ffe47995bbbaff531af453746f3365fe01947c1ea8d98a7ae3ab52b46426
# via aws-sam-cli (setup.py)
aws-sam-translator==1.64.0 \
--hash=sha256:0cc5b07dd6ef1de3525d887a3b9557168e04cb44327706a43661653bad30687f \
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.80.0"
__version__ = "1.81.0"
2 changes: 1 addition & 1 deletion samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
1. Python 3.7, 3.8, 3.9, 3.10 using PIP\n
2. Nodejs 18.x, 16.x, 14.x, 12.x using NPM\n
3. Ruby 2.7 using Bundler\n
4. Java 8, Java 11 using Gradle and Maven\n
4. Java 8, Java 11, Java 17 using Gradle and Maven\n
5. Dotnetcore 3.1, Dotnet6 using Dotnet CLI (without --use-container)\n
6. Go 1.x using Go Modules (without --use-container)\n
"""
Expand Down
9 changes: 9 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def get_layer_subfolder(build_workflow: str) -> str:
"java8": "java",
"java11": "java",
"java8.al2": "java",
"java17": "java",
"dotnet6": "dotnet",
# User is responsible for creating subfolder in these workflows
"makefile": "",
Expand Down Expand Up @@ -187,6 +188,14 @@ def get_workflow_config(
JAVA_MAVEN_CONFIG,
]
),
"java17": ManifestWorkflowSelector(
[
# Gradle builder needs custom executable paths to find `gradlew` binary
JAVA_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_KOTLIN_GRADLE_CONFIG._replace(executable_search_paths=[code_dir, project_dir]),
JAVA_MAVEN_CONFIG,
]
),
"provided": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
"provided.al2": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG),
}
Expand Down
4 changes: 3 additions & 1 deletion samcli/lib/deploy/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def has_stack(self, stack_name):
if "Stack with id {0} does not exist".format(stack_name) in str(e):
LOG.debug("Stack with id %s does not exist", stack_name)
return False
return None

LOG.debug("Unknown ClientError recieved: %s. Cannot determine if stack exists.", str(e))
raise DeployFailedError(stack_name=stack_name, msg=str(e)) from e
except botocore.exceptions.BotoCoreError as e:
# If there are credentials, environment errors,
# catch that and throw a deploy failed error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


class ApplicationInsightsTemplateModifier(TemplateModifier):

TYPE_KEY = "Type"
RESOURCES_KEY = "Resources"
PROPERTIES_KEY = "Properties"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class XRayTracingTemplateModifier(TemplateModifier):

FIELD_NAME_FUNCTION_TRACING = "Tracing"
FIELD_NAME_API_TRACING = "TracingEnabled"
GLOBALS = "Globals"
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/providers/api_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ def _link_authorizers(self) -> None:
continue

if not authorizer_object and authorizer_name_lookup:
route.authorizer_name = None

LOG.info(
"Linking authorizer skipped for route '%s', authorizer '%s' is unsupported or not found",
route.path,
route.authorizer_name,
)

route.authorizer_name = None

def add_routes(self, logical_id: str, routes: List[Route]) -> None:
"""
Stores the given routes tagged under the given logicalId
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 @@ -26,6 +26,7 @@
"java8": [X86_64],
"java8.al2": [ARM64, X86_64],
"java11": [ARM64, X86_64],
"java17": [ARM64, X86_64],
"go1.x": [X86_64],
"dotnetcore3.1": [ARM64, X86_64],
"dotnet6": [ARM64, 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] = {"java17"}
14 changes: 13 additions & 1 deletion samcli/local/apigw/local_apigw_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,17 @@ def _request_handler(self, **kwargs):
except InvalidLambdaAuthorizerResponse as ex:
auth_service_error = ServiceErrorResponses.lambda_failure_response()
lambda_authorizer_exception = ex
except FunctionNotFound as ex:
lambda_authorizer_exception = ex

LOG.warning(
"Failed to find a Function to invoke a Lambda authorizer, verify that "
"this Function exists locally if it is not a remote resource."
)
except Exception as ex:
# re-raise the catch all exception after we track it in our telemetry
lambda_authorizer_exception = ex
raise ex
finally:
exception_name = type(lambda_authorizer_exception).__name__ if lambda_authorizer_exception else None

Expand All @@ -690,8 +701,9 @@ def _request_handler(self, **kwargs):
)

if lambda_authorizer_exception:
LOG.error("Lambda authorizer failed to invoke successfully: %s", lambda_authorizer_exception.message)
LOG.error("Lambda authorizer failed to invoke successfully: %s", exception_name)

if auth_service_error:
return auth_service_error

endpoint_service_error = None
Expand Down
7 changes: 5 additions & 2 deletions samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
],
"java": [
{
"runtimes": ["java11", "java8", "java8.al2"],
"runtimes": ["java11", "java8", "java8.al2", "java17"],
"dependency_manager": "maven",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-java-maven"),
"build": True,
},
{
"runtimes": ["java11", "java8", "java8.al2"],
"runtimes": ["java11", "java8", "java8.al2", "java17"],
"dependency_manager": "gradle",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-java-gradle"),
"build": True,
Expand Down Expand Up @@ -102,6 +102,7 @@ def get_local_lambda_images_location(mapping, runtime):
"dotnetcore3.1",
"go1.x",
# java runtimes in descending order
"java17",
"java11",
"java8.al2",
"java8",
Expand Down Expand Up @@ -129,6 +130,7 @@ def get_local_lambda_images_location(mapping, runtime):
"dotnetcore3.1": "amazon/dotnetcore3.1-base",
"go1.x": "amazon/go1.x-base",
"go (provided.al2)": "amazon/go-provided.al2-base",
"java17": "amazon/java17-base",
"java11": "amazon/java11-base",
"java8.al2": "amazon/java8.al2-base",
"java8": "amazon/java8-base",
Expand All @@ -151,6 +153,7 @@ def get_local_lambda_images_location(mapping, runtime):
"java8": "Java8",
"java8.al2": "Java8",
"java11": "Java8",
"java17": "Java17",
"python3.7": "Python36",
"python3.8": "Python36",
"python3.9": "Python36",
Expand Down
10 changes: 10 additions & 0 deletions samcli/local/docker/lambda_debug_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
**_container_env_vars,
},
),
Runtime.java17.value: lambda: DebugSettings(
entry,
container_env_vars={
"_JAVA_OPTIONS": "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,quiet=y,"
f"address=*:{debug_port} -XX:MaxHeapSize=2834432k -XX:+UseSerialGC "
"-XX:+TieredCompilation -XX:TieredStopAtLevel=1 "
"-Djava.net.preferIPv4Stack=true" + " ".join(debug_args_list),
**_container_env_vars,
},
),
Runtime.dotnetcore31.value: lambda: DebugSettings(
entry + ["/var/runtime/bootstrap"] + debug_args_list,
container_env_vars={"_AWS_LAMBDA_DOTNET_DEBUGGING": "1", **_container_env_vars},
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):
java8 = "java8"
java8al2 = "java8.al2"
java11 = "java11"
java17 = "java17"
go1x = "go1.x"
dotnetcore31 = "dotnetcore3.1"
dotnet6 = "dotnet6"
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": "b4a2b2ee5d0dc2d03d1f65385fa8c21bafd097f3"
"app_template_repo_commit": "6777f618c08af939c4f10cb6404c238a2d06fd34"
}
5 changes: 3 additions & 2 deletions tests/integration/buildcmd/build_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def verify_pulled_image(self, runtime, architecture=X86_64):
self.assertIn(
len(images),
[1, 2],
f"Other version of the build image {image_name} was pulled. Currently pulled images: {images}",
f"Other version of the build image {image_name} was pulled. Currently pulled images: {images}, architecture: {architecture}, tag: {tag_name}",
)
image_tag = f"{image_name}:{tag_name}"
for t in [tag for image in images for tag in image.tags]:
Expand Down Expand Up @@ -820,7 +820,8 @@ def _verify_build_and_invoke_functions(self, expected_messages, command_result,
expected = f"Hello {expected_message}"
function_id = f"Hello{expected_message}Function"
self._verify_build_artifact(self.default_build_dir, function_id)
self._verify_invoke_built_function(self.built_template, function_id, overrides, expected)
if not SKIP_DOCKER_TESTS:
self._verify_invoke_built_function(self.built_template, function_id, overrides, expected)

def _verify_build_artifact(self, build_dir, function_logical_id):
self.assertTrue(build_dir.exists(), "Build directory should be created")
Expand Down
Loading

0 comments on commit 6c45ed9

Please sign in to comment.