From 20552562aa80843fe5cb5e569b5e58daaf569741 Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Fri, 21 Oct 2022 11:03:10 -0700 Subject: [PATCH] fix: Skips the runtime test when building in docker (#362) Co-authored-by: Allan Benson <95691842+AllanBenson001@users.noreply.github.com> --- README.md | 4 ++++ package.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d90105d1..296b34ab 100644 --- a/README.md +++ b/README.md @@ -470,6 +470,10 @@ Using this module you can install dependencies from private hosts. To do this, y docker_with_ssh_agent = true +Note that by default, the `docker_image` used comes from the registry `public.ecr.aws/sam/`, and will be based on the `runtime` that you specify. In other words, if you specify a runtime of `python3.8` and do not specify `docker_image`, then the `docker_image` will resolve to `public.ecr.aws/sam/build-python3.8`. This ensures that by default the `runtime` is available in the docker container. + +If you override `docker_image`, be sure to keep the image in sync with your `runtime`. During the plan phase, when using docker, there is no check that the `runtime` is available to build the package. That means that if you use an image that does not have the runtime, the plan will still succeed, but then the apply will fail. + ## Deployment package - Create or use existing By default, this module creates deployment package and uses it to create or update Lambda Function or Lambda Layer. diff --git a/package.py b/package.py index b378d44e..79b2ea67 100644 --- a/package.py +++ b/package.py @@ -657,7 +657,7 @@ def pip_requirements_step(path, prefix=None, required=False, tmp_dir=None): raise RuntimeError( 'File not found: {}'.format(requirements)) else: - if not shutil.which(runtime): + if not query.docker and not shutil.which(runtime): raise RuntimeError( "Python interpreter version equal " "to defined lambda runtime ({}) should be " @@ -675,7 +675,7 @@ def npm_requirements_step(path, prefix=None, required=False, tmp_dir=None): raise RuntimeError( 'File not found: {}'.format(requirements)) else: - if not shutil.which(runtime): + if not query.docker and not shutil.which(runtime): raise RuntimeError( "Nodejs interpreter version equal " "to defined lambda runtime ({}) should be "