Skip to content

Commit

Permalink
fix: remove deprecated runtime support for nodejs10.x, ruby2.5, dotne…
Browse files Browse the repository at this point in the history
…tcore2.1 and python2.7 (#3611)

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

* remove dotnetcore2.1 related templates & tests

Co-authored-by: Daniel Mil <[email protected]>
  • Loading branch information
mndeveci and mildaniel authored Feb 19, 2022
1 parent 80eccbe commit 15f271f
Show file tree
Hide file tree
Showing 37 changed files with 157 additions and 297 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
7 changes: 4 additions & 3 deletions samcli/commands/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from samcli.lib.telemetry.metric import track_command
from samcli.commands.init.interactive_init_flow import _get_runtime_from_image, get_architectures, get_sorted_runtimes
from samcli.commands._utils.click_mutex import ClickMutex
from samcli.lib.build.app_builder import DEPRECATED_RUNTIMES
from samcli.lib.utils.packagetype import IMAGE, ZIP
from samcli.lib.utils.architecture import X86_64, ARM64

Expand Down Expand Up @@ -362,11 +363,11 @@ def do_cli(
def _deprecate_notification(runtime):
from samcli.lib.utils.colors import Colored

deprecated_runtimes = {"dotnetcore1.0", "dotnetcore2.0"}
if runtime in 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. "
f"See issue: https://github.com/awslabs/aws-sam-cli/issues/1934 for more details."
"For more information please check AWS Lambda Runtime Support Policy: "
"https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
)
LOG.warning(Colored().yellow(message))

Expand Down
4 changes: 2 additions & 2 deletions samcli/commands/init/init_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"project_name": "Name of the project",
"runtime": "dotnetcore2.1",
"runtime": "dotnetcore3.1",
"architectures": {
"value": [
"x86_64"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
{%- if cookiecutter.runtime == 'dotnetcore2.1' %}
<TargetFramework>netcoreapp2.1</TargetFramework>
{%- else %}
{%- if cookiecutter.runtime == '3.1' %}
<TargetFramework>netcoreapp3.1</TargetFramework>
{%- endif %}
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"profile":"",
"region" : "",
"configuration": "Release",
{%- if cookiecutter.runtime == 'dotnetcore2.1' %}
"framework": "netcoreapp2.1",
{%- else %}
{%- if cookiecutter.runtime == 'dotnetcore3.1' %}
"framework" : "netcoreapp3.1",
{%- endif %}
"function-runtime":"{{ cookiecutter.runtime }}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Resources:
Properties:
CodeUri: ./src/HelloWorld/
Handler: HelloWorld::HelloWorld.Function::FunctionHandler
{%- if cookiecutter.runtime == 'dotnetcore2.1' %}
Runtime: {{ cookiecutter.runtime }}
{%- else %}
{%- if cookiecutter.runtime == 'dotnetcore3.1' %}
Runtime: dotnetcore3.1
{%- endif %}
Architectures:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
{%- if cookiecutter.runtime == 'dotnetcore2.0' %}
<TargetFramework>netcoreapp2.0</TargetFramework>
{%- elif cookiecutter.runtime == 'dotnetcore2.1' %}
<TargetFramework>netcoreapp2.1</TargetFramework>
{%- else %}
{%- if cookiecutter.runtime == 'dotnetcore3.1' %}
<TargetFramework>netcoreapp3.1</TargetFramework>
{%- endif %}
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
10 changes: 5 additions & 5 deletions samcli/lib/providers/sam_function_provider.py
Original file line number Diff line number Diff line change
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,11 +131,11 @@ 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 "
"See issue: https://github.com/awslabs/aws-sam-cli/issues/1934 for more details."
f"WARNING: {runtime} is no longer supported by AWS Lambda, please update to a newer supported "
"runtime. For more information please check AWS Lambda Runtime Support Policy: "
"https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html"
)
LOG.warning(self._colored.yellow(message))

Expand Down
4 changes: 0 additions & 4 deletions samcli/lib/utils/architecture.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 15f271f

Please sign in to comment.