Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove deprecated runtime support for nodejs10.x, ruby2.5, dotnetcore2.1 and python2.7 #3611

Merged
merged 5 commits into from Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -32,7 +32,7 @@ Contributions via pull requests are much appreciated. Before sending us a pull r
1. You are working against the latest source on the *develop* branch.
2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
4. The change works in both Python2.7 and Python3.6 (support Python Versions)
4. The change works in Python3 (see supported Python Versions in setup.py)
5. Does the PR have updated/added unit, functional, and integration tests?
6. PR is merged submitted to merge into develop.

Expand Down
8 changes: 4 additions & 4 deletions samcli/commands/build/command.py
Expand Up @@ -40,11 +40,11 @@
\b
Supported Runtimes
------------------
1. Python 2.7, 3.6, 3.7, 3.8 3.9 using PIP\n
2. Nodejs 14.x, 12.x, 10.x, 8.10, 6.10 using NPM\n
3. Ruby 2.5 using Bundler\n
1. Python 3.6, 3.7, 3.8 3.9 using PIP\n
2. Nodejs 14.x, 12.x using NPM\n
3. Ruby 2.7 using Bundler\n
4. Java 8, Java 11 using Gradle and Maven\n
5. Dotnetcore2.0 and 2.1 using Dotnet CLI (without --use-container flag)\n
5. Dotnetcore3.1 using Dotnet CLI (without --use-container flag)\n
6. Go 1.x using Go Modules (without --use-container flag)\n
\b
Examples
Expand Down
4 changes: 2 additions & 2 deletions samcli/commands/init/init_templates.py
Expand Up @@ -145,9 +145,9 @@ def get_preprocessed_manifest(
https://github.com/aws/aws-sam-cli-app-templates/blob/master/manifest.json
The structure of the manifest is shown below:
{
"dotnetcore2.1": [
"dotnetcore3.1": [
{
"directory": "dotnetcore2.1/cookiecutter-aws-sam-hello-dotnet",
"directory": "dotnetcore3.1/cookiecutter-aws-sam-hello-dotnet",
"displayName": "Hello World Example",
"dependencyManager": "cli-package",
"appTemplate": "hello-world",
Expand Down
22 changes: 17 additions & 5 deletions samcli/lib/build/app_builder.py
Expand Up @@ -6,7 +6,7 @@
import json
import logging
import pathlib
from typing import List, Optional, Dict, cast, Union, NamedTuple
from typing import List, Optional, Dict, cast, Union, NamedTuple, Set

import docker
import docker.errors
Expand Down Expand Up @@ -59,10 +59,21 @@
get_layer_subfolder,
supports_build_in_container,
CONFIG,
UnsupportedRuntimeException,
)

LOG = logging.getLogger(__name__)

DEPRECATED_RUNTIMES: Set[str] = {
"nodejs4.3",
"nodejs6.10",
"nodejs8.10",
"nodejs10.x",
"dotnetcore2.0",
"dotnetcore2.1",
"python2.7",
"ruby2.5",
}
BUILD_PROPERTIES = "BuildProperties"


Expand Down Expand Up @@ -156,7 +167,7 @@ def __init__(
self._stream_writer = stream_writer if stream_writer else StreamWriter(stream=osutils.stderr(), auto_flush=True)
self._docker_client = docker_client if docker_client else docker.from_env()

self._deprecated_runtimes = {"nodejs4.3", "nodejs6.10", "nodejs8.10", "dotnetcore2.0"}
self._deprecated_runtimes = DEPRECATED_RUNTIMES
self._colored = Colored()
self._container_env_var = container_env_var
self._container_env_var_file = container_env_var_file
Expand Down Expand Up @@ -600,11 +611,12 @@ def _build_function( # pylint: disable=R1710
if packagetype == ZIP:
if runtime in self._deprecated_runtimes:
message = (
f"WARNING: {runtime} is no longer supported by AWS Lambda, "
"please update to a newer supported runtime. SAM CLI "
"See issue: https://github.com/awslabs/aws-sam-cli/issues/1934 for more details."
f"Building functions with {runtime} is no longer supported by AWS SAM CLI, please "
f"update to a newer supported runtime. For more information please check AWS Lambda Runtime "
f"Support Policy: https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
)
LOG.warning(self._colored.yellow(message))
raise UnsupportedRuntimeException(f"Building functions with {runtime} is no longer supported")

# Create the arguments to pass to the builder
# Code is always relative to the given base directory.
Expand Down
9 changes: 1 addition & 8 deletions samcli/lib/build/workflow_config.py
Expand Up @@ -155,18 +155,15 @@ def get_selector(

def get_layer_subfolder(build_workflow: str) -> str:
subfolders_by_runtime = {
"python2.7": "python",
"python3.6": "python",
"python3.7": "python",
"python3.8": "python",
"python3.9": "python",
"nodejs4.3": "nodejs",
"nodejs6.10": "nodejs",
"nodejs8.10": "nodejs",
"nodejs10.x": "nodejs",
"nodejs12.x": "nodejs",
"nodejs14.x": "nodejs",
"ruby2.5": "ruby/lib",
"ruby2.7": "ruby/lib",
"java8": "java",
"java11": "java",
Expand Down Expand Up @@ -203,7 +200,7 @@ def get_workflow_config(

specified_workflow str
Workflow to be used, if directly specified. They are currently scoped to "makefile" and the official runtime
identifier names themselves, eg: nodejs10.x. If a workflow is not directly specified,
identifier names themselves, eg: nodejs14.x. If a workflow is not directly specified,
it is calculated by the current method based on the runtime.

Returns
Expand All @@ -215,17 +212,13 @@ def get_workflow_config(
selectors_by_build_method = {"makefile": BasicWorkflowSelector(PROVIDED_MAKE_CONFIG)}

selectors_by_runtime = {
"python2.7": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.6": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.7": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.8": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.9": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"nodejs10.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs12.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs14.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"ruby2.5": BasicWorkflowSelector(RUBY_BUNDLER_CONFIG),
"ruby2.7": BasicWorkflowSelector(RUBY_BUNDLER_CONFIG),
"dotnetcore2.1": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"dotnetcore3.1": BasicWorkflowSelector(DOTNET_CLIPACKAGE_CONFIG),
"go1.x": BasicWorkflowSelector(GO_MOD_CONFIG),
# When Maven builder exists, add to this list so we can automatically choose a builder based on the supported
Expand Down
Expand Up @@ -12,7 +12,6 @@ Generate a boilerplate template in your current project directory using the foll

* **Python 3.7**: `sam init --runtime python3.7`
* **Python 3.6**: `sam init --runtime python3.6`
* **Python 2.7**: `sam init --runtime python2.7`

> **NOTE**: ``--name`` allows you to specify a different project folder name (`sam-app` is the default)

Expand Down
Expand Up @@ -30,11 +30,7 @@ The Serverless Application Model Command Line Interface (SAM CLI) is an extensio
To use the SAM CLI, you need the following tools.

* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
{%- if cookiecutter.runtime == 'python2.7' %}
* [Python 2.7 installed](https://www.python.org/downloads/)
{%- else %}
* [Python 3 installed](https://www.python.org/downloads/)
{%- endif %}
* [Python 3 installed]
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)

To build and deploy your application for the first time, run the following in your shell:
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/providers/sam_function_provider.py
Expand Up @@ -21,6 +21,7 @@
from .provider import Function, LayerVersion, Stack
from .sam_base_provider import SamBaseProvider
from .sam_stack_provider import SamLocalStackProvider
from ..build.app_builder import DEPRECATED_RUNTIMES

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -62,7 +63,6 @@ def __init__(
self._stacks, use_raw_codeuri, ignore_code_extraction_warnings
)

self._deprecated_runtimes = {"nodejs4.3", "nodejs6.10", "nodejs8.10", "dotnetcore2.0"}
self._colored = Colored()

@property
Expand Down Expand Up @@ -131,7 +131,7 @@ def get(self, name: str) -> Optional[Function]:
return resolved_function

def _deprecate_notification(self, runtime: Optional[str]) -> None:
if runtime in self._deprecated_runtimes:
if runtime in DEPRECATED_RUNTIMES:
message = (
f"WARNING: {runtime} is no longer supported by AWS Lambda, "
"please update to a newer supported runtime. SAM CLI "
Expand Down
4 changes: 0 additions & 4 deletions samcli/lib/utils/architecture.py
Expand Up @@ -14,21 +14,17 @@
ARM64 = "arm64"

SUPPORTED_RUNTIMES: Dict[str, List[str]] = {
"nodejs10.x": [X86_64],
"nodejs12.x": [ARM64, X86_64],
"nodejs14.x": [ARM64, X86_64],
"python2.7": [X86_64],
"python3.6": [X86_64],
"python3.7": [X86_64],
"python3.8": [ARM64, X86_64],
"python3.9": [ARM64, X86_64],
"ruby2.5": [X86_64],
"ruby2.7": [ARM64, X86_64],
"java8": [X86_64],
"java8.al2": [ARM64, X86_64],
"java11": [ARM64, X86_64],
"go1.x": [X86_64],
"dotnetcore2.1": [X86_64],
"dotnetcore3.1": [ARM64, X86_64],
"provided": [X86_64],
"provided.al2": [ARM64, X86_64],
Expand Down
20 changes: 4 additions & 16 deletions samcli/local/common/runtime_template.py
Expand Up @@ -15,31 +15,31 @@
RUNTIME_DEP_TEMPLATE_MAPPING = {
"python": [
{
"runtimes": ["python3.9", "python3.8", "python3.7", "python3.6", "python2.7"],
"runtimes": ["python3.9", "python3.8", "python3.7", "python3.6"],
"dependency_manager": "pip",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"),
"build": True,
}
],
"ruby": [
{
"runtimes": ["ruby2.5", "ruby2.7"],
"runtimes": ["ruby2.7"],
"dependency_manager": "bundler",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-ruby"),
"build": True,
}
],
"nodejs": [
{
"runtimes": ["nodejs14.x", "nodejs12.x", "nodejs10.x"],
"runtimes": ["nodejs14.x", "nodejs12.x"],
"dependency_manager": "npm",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-nodejs"),
"build": True,
}
],
"dotnet": [
{
"runtimes": ["dotnetcore3.1", "dotnetcore2.1"],
"runtimes": ["dotnetcore3.1"],
"dependency_manager": "cli-package",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-dotnet"),
"build": True,
Expand Down Expand Up @@ -87,14 +87,10 @@ def get_local_lambda_images_location(mapping, runtime):
"python3.8": ["pip"],
"python3.7": ["pip"],
"python3.6": ["pip"],
"python2.7": ["pip"],
"ruby2.5": ["bundler"],
"ruby2.7": ["bundler"],
"nodejs14.x": ["npm"],
"nodejs12.x": ["npm"],
"nodejs10.x": ["npm"],
"dotnetcore3.1": ["cli-package"],
"dotnetcore2.1": ["cli-package"],
"go1.x": ["mod"],
"java8": ["maven", "gradle"],
"java11": ["maven", "gradle"],
Expand All @@ -119,7 +115,6 @@ def get_local_lambda_images_location(mapping, runtime):
# dotnetcore runtimes in descending order
"dotnet5.0",
"dotnetcore3.1",
"dotnetcore2.1",
"go1.x",
# java runtimes in descending order
"java11",
Expand All @@ -128,37 +123,30 @@ def get_local_lambda_images_location(mapping, runtime):
# nodejs runtimes in descending order
"nodejs14.x",
"nodejs12.x",
"nodejs10.x",
# python runtimes in descending order
"python3.9",
"python3.8",
"python3.7",
"python3.6",
"python2.7",
# ruby runtimes in descending order
"ruby2.7",
"ruby2.5",
]


LAMBDA_IMAGES_RUNTIMES_MAP = {
"dotnet5.0": "amazon/dotnet5.0-base",
"dotnetcore3.1": "amazon/dotnetcore3.1-base",
"dotnetcore2.1": "amazon/dotnetcore2.1-base",
"go1.x": "amazon/go1.x-base",
"java11": "amazon/java11-base",
"java8.al2": "amazon/java8.al2-base",
"java8": "amazon/java8-base",
"nodejs14.x": "amazon/nodejs14.x-base",
"nodejs12.x": "amazon/nodejs12.x-base",
"nodejs10.x": "amazon/nodejs10.x-base",
"python3.9": "amazon/python3.9-base",
"python3.8": "amazon/python3.8-base",
"python3.7": "amazon/python3.7-base",
"python3.6": "amazon/python3.6-base",
"python2.7": "amazon/python2.7-base",
"ruby2.7": "amazon/ruby2.7-base",
"ruby2.5": "amazon/ruby2.5-base",
}

LAMBDA_IMAGES_RUNTIMES = LAMBDA_IMAGES_RUNTIMES_MAP.values()
Expand Down
22 changes: 0 additions & 22 deletions samcli/local/docker/lambda_debug_settings.py
Expand Up @@ -83,10 +83,6 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
**_container_env_vars,
},
),
Runtime.dotnetcore21.value: lambda: DebugSettings(
entry + ["/var/runtime/bootstrap"] + debug_args_list,
container_env_vars={"_AWS_LAMBDA_DOTNET_DEBUGGING": "1", **_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 All @@ -101,20 +97,6 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
**_container_env_vars,
},
),
Runtime.nodejs10x.value: lambda: DebugSettings(
entry
+ ["/var/lang/bin/node"]
+ debug_args_list
+ ["--no-lazy", "--expose-gc"]
+ ["/var/runtime/index.js"],
container_env_vars={
"NODE_PATH": "/opt/nodejs/node_modules:/opt/nodejs/node10/node_modules:/var/runtime/node_modules:"
"/var/runtime:/var/task",
"NODE_OPTIONS": f"--inspect-brk=0.0.0.0:{str(debug_port)} --max-http-header-size 81920",
"AWS_EXECUTION_ENV": "AWS_Lambda_nodejs10.x",
**_container_env_vars,
},
),
Runtime.nodejs12x.value: lambda: DebugSettings(
entry
+ ["/var/lang/bin/node"]
Expand Down Expand Up @@ -143,10 +125,6 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
**_container_env_vars,
},
),
Runtime.python27.value: lambda: DebugSettings(
entry + ["/usr/bin/python2.7"] + debug_args_list + ["/var/runtime/awslambda/bootstrap.py"],
container_env_vars=_container_env_vars,
),
Runtime.python36.value: lambda: DebugSettings(
entry + ["/var/lang/bin/python3.6"] + debug_args_list + ["/var/runtime/awslambda/bootstrap.py"],
container_env_vars=_container_env_vars,
Expand Down
4 changes: 0 additions & 4 deletions samcli/local/docker/lambda_image.py
Expand Up @@ -27,21 +27,17 @@


class Runtime(Enum):
nodejs10x = "nodejs10.x"
nodejs12x = "nodejs12.x"
nodejs14x = "nodejs14.x"
python27 = "python2.7"
python36 = "python3.6"
python37 = "python3.7"
python38 = "python3.8"
python39 = "python3.9"
ruby25 = "ruby2.5"
ruby27 = "ruby2.7"
java8 = "java8"
java8al2 = "java8.al2"
java11 = "java11"
go1x = "go1.x"
dotnetcore21 = "dotnetcore2.1"
dotnetcore31 = "dotnetcore3.1"
provided = "provided"
providedal2 = "provided.al2"
Expand Down