From 58b78bba2f036244b5dc4ffc9616d5f91f1bc967 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Wed, 21 Sep 2022 15:20:26 -0700 Subject: [PATCH] Use Amazon ECR images for mimicing lambda with docker --- python/rpdk/python/codegen.py | 5 ++++- tests/plugin/codegen_test.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python/rpdk/python/codegen.py b/python/rpdk/python/codegen.py index 2f272fc6..47f475da 100644 --- a/python/rpdk/python/codegen.py +++ b/python/rpdk/python/codegen.py @@ -43,6 +43,7 @@ class Python36LanguagePlugin(LanguagePlugin): RESOURCE_ENTRY_POINT = "{}.handlers.resource" TEST_ENTRY_POINT = "{}.handlers.test_entrypoint" CODE_URI = "build/" + DOCKER_TAG = 3.6 def __init__(self): self.env = self._setup_jinja_env( @@ -274,7 +275,7 @@ def _docker_build(cls, external_path): LOG.debug("command is '%s'", command) volumes = {str(external_path): {"bind": str(internal_path), "mode": "rw"}} - image = f"lambci/lambda:build-{cls.RUNTIME}" + image = f"public.ecr.aws/lambda/python:{cls.DOCKER_TAG}" LOG.warning( "Starting Docker build. This may take several minutes if the " "image '%s' needs to be pulled first.", @@ -288,6 +289,7 @@ def _docker_build(cls, external_path): auto_remove=True, volumes=volumes, stream=True, + entrypoint="", user=f"{os.geteuid()}:{os.getgid()}", ) except RequestsConnectionError as e: @@ -325,3 +327,4 @@ def _pip_build(cls, base_path): class Python37LanguagePlugin(Python36LanguagePlugin): NAME = "python37" RUNTIME = "python3.7" + DOCKER_TAG = 3.7 diff --git a/tests/plugin/codegen_test.py b/tests/plugin/codegen_test.py index 326ee742..68f993e9 100644 --- a/tests/plugin/codegen_test.py +++ b/tests/plugin/codegen_test.py @@ -438,6 +438,7 @@ def test__docker_build_good_path(plugin, tmp_path): auto_remove=True, volumes={str(tmp_path): {"bind": "/project", "mode": "rw"}}, stream=True, + entrypoint="", user=ANY, ) @@ -479,5 +480,6 @@ def test__docker_build_bad_path(plugin, tmp_path, exception): auto_remove=True, volumes={str(tmp_path): {"bind": "/project", "mode": "rw"}}, stream=True, + entrypoint="", user=ANY, )