From df79afe8b4a63848bf36f5d12af4982a4512e19c Mon Sep 17 00:00:00 2001
From: Wing Fung Lau <4760060+hawflau@users.noreply.github.com>
Date: Thu, 9 Nov 2023 07:40:35 -0800
Subject: [PATCH] Revert "Revert "Provided.al2023 runtime (#516) (#6061)"
 (#6070)" (#6217)

This reverts commit 5040a08b87d8f98328a9e5236b9a783f6befe06e.
---
 samcli/lib/build/workflow_config.py                 |  1 +
 samcli/lib/utils/architecture.py                    |  1 +
 samcli/local/common/runtime_template.py             |  4 +++-
 samcli/local/docker/lambda_image.py                 |  1 +
 schema/samcli.json                                  |  8 +++++---
 tests/integration/buildcmd/test_build_cmd.py        |  5 +++++
 tests/integration/buildcmd/test_build_cmd_arm64.py  | 10 ++++++++++
 tests/integration/validate/test_validate_command.py |  1 +
 tests/unit/lib/build_module/test_workflow_config.py |  2 +-
 tests/unit/local/docker/test_lambda_image.py        |  1 +
 10 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/samcli/lib/build/workflow_config.py b/samcli/lib/build/workflow_config.py
index 713c57a751..29ba64bd06 100644
--- a/samcli/lib/build/workflow_config.py
+++ b/samcli/lib/build/workflow_config.py
@@ -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 = {
diff --git a/samcli/lib/utils/architecture.py b/samcli/lib/utils/architecture.py
index 0121d5d8f0..33345db49b 100644
--- a/samcli/lib/utils/architecture.py
+++ b/samcli/lib/utils/architecture.py
@@ -33,6 +33,7 @@
     "dotnet6": [ARM64, X86_64],
     "provided": [X86_64],
     "provided.al2": [ARM64, X86_64],
+    "provided.al2023": [ARM64, X86_64],
 }
 
 
diff --git a/samcli/local/common/runtime_template.py b/samcli/local/common/runtime_template.py
index c999e33982..c41a56862f 100644
--- a/samcli/local/common/runtime_template.py
+++ b/samcli/local/common/runtime_template.py
@@ -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
@@ -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",
@@ -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):
diff --git a/samcli/local/docker/lambda_image.py b/samcli/local/docker/lambda_image.py
index a8272b3c2c..cd0c93affd 100644
--- a/samcli/local/docker/lambda_image.py
+++ b/samcli/local/docker/lambda_image.py
@@ -51,6 +51,7 @@ class Runtime(Enum):
     dotnet6 = "dotnet6"
     provided = "provided"
     providedal2 = "provided.al2"
+    providedal2023 = "provided.al2023"
 
     @classmethod
     def has_value(cls, value):
diff --git a/schema/samcli.json b/schema/samcli.json
index a77dd6f40a..e1acd5bfad 100644
--- a/schema/samcli.json
+++ b/schema/samcli.json
@@ -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": {
@@ -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",
@@ -62,6 +62,7 @@
                     "nodejs18.x",
                     "provided",
                     "provided.al2",
+                    "provided.al2023",
                     "python3.10",
                     "python3.11",
                     "python3.7",
@@ -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",
diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py
index e71a76355b..1b9648af24 100644
--- a/tests/integration/buildcmd/test_build_cmd.py
+++ b/tests/integration/buildcmd/test_build_cmd.py
@@ -1566,6 +1566,8 @@ class TestBuildCommand_ProvidedFunctions(BuildIntegProvidedBase):
             ("provided", "use_container", "Makefile-container"),
             ("provided.al2", False, None),
             ("provided.al2", "use_container", "Makefile-container"),
+            ("provided.al2023", False, None),
+            ("provided.al2023", "use_container", "Makefile-container"),
         ]
     )
     def test_building_Makefile(self, runtime, use_container, manifest):
@@ -1590,6 +1592,8 @@ class TestBuildCommand_ProvidedFunctions_With_Specified_Architecture(BuildIntegP
             ("provided", "use_container", "Makefile-container", "x86_64"),
             ("provided.al2", False, None, "x86_64"),
             ("provided.al2", "use_container", "Makefile-container", "x86_64"),
+            ("provided.al2023", False, None, "x86_64"),
+            ("provided.al2023", "use_container", "Makefile-container", "x86_64"),
         ]
     )
     def test_building_Makefile(self, runtime, use_container, manifest, architecture):
@@ -1617,6 +1621,7 @@ class TestBuildCommand_ProvidedFunctionsWithCustomMetadata(BuildIntegProvidedBas
         [
             ("provided", False, None),
             ("provided.al2", False, None),
+            ("provided.al2023", False, None),
         ]
     )
     def test_building_Makefile(self, runtime, use_container, manifest):
diff --git a/tests/integration/buildcmd/test_build_cmd_arm64.py b/tests/integration/buildcmd/test_build_cmd_arm64.py
index cb78a3a233..dc4bcd7723 100644
--- a/tests/integration/buildcmd/test_build_cmd_arm64.py
+++ b/tests/integration/buildcmd/test_build_cmd_arm64.py
@@ -429,6 +429,16 @@ class TestBuildCommand_ProvidedFunctions_With_Specified_Architecture_arm64(Build
                 "use_container",
                 "Makefile-container",
             ),
+            (
+                "provided.al2023",
+                False,
+                None,
+            ),
+            (
+                "provided.al2023",
+                "use_container",
+                "Makefile-container",
+            ),
         ]
     )
     def test_building_Makefile(self, runtime, use_container, manifest):
diff --git a/tests/integration/validate/test_validate_command.py b/tests/integration/validate/test_validate_command.py
index 9e0b6d9540..cc25a87535 100644
--- a/tests/integration/validate/test_validate_command.py
+++ b/tests/integration/validate/test_validate_command.py
@@ -142,6 +142,7 @@ def test_lint_supported_runtimes(self):
             "nodejs18.x",
             "provided",
             "provided.al2",
+            "provided.al2023",
             "python3.7",
             "python3.8",
             "python3.9",
diff --git a/tests/unit/lib/build_module/test_workflow_config.py b/tests/unit/lib/build_module/test_workflow_config.py
index 9a1beaccfd..e51ff0ba50 100644
--- a/tests/unit/lib/build_module/test_workflow_config.py
+++ b/tests/unit/lib/build_module/test_workflow_config.py
@@ -69,7 +69,7 @@ def test_must_mount_with_write_for_dotnet_in_container(self, runtime, specified_
         result = get_workflow_config(runtime, self.code_dir, self.project_dir, specified_workflow)
         self.assertTrue(result.must_mount_with_write_in_container)
 
-    @parameterized.expand([("provided.al2",)])
+    @parameterized.expand([("provided.al2",), ("provided.al2023",)])
     def test_must_work_for_provided_with_build_method_rustcargolambda(self, runtime):
         result = get_workflow_config(runtime, self.code_dir, self.project_dir, specified_workflow="rust-cargolambda")
         self.assertEqual(result.language, "rust")
diff --git a/tests/unit/local/docker/test_lambda_image.py b/tests/unit/local/docker/test_lambda_image.py
index 03b57be804..fa64833ab3 100644
--- a/tests/unit/local/docker/test_lambda_image.py
+++ b/tests/unit/local/docker/test_lambda_image.py
@@ -35,6 +35,7 @@ class TestRuntime(TestCase):
             ("dotnet6", "dotnet:6-x86_64"),
             ("provided", "provided:alami"),
             ("provided.al2", "provided:al2-x86_64"),
+            ("provided.al2023", "provided:al2023-x86_64"),
         ]
     )
     def test_image_name_tag(self, runtime, image_tag):